qtnetwork

Get the ping from a remote target with Qt (Windows/Linux)

拜拜、爱过 提交于 2019-12-04 02:49:41
Currently I use this code for retrieving the ping of a target system. However it works so far only under linux and it is likely dependent on the locale settings. To add support for windows will be likely even more complicated. Is there an easy way or library to get the ping of a target system? I mainly work with Qt, so it would be ideal if I could work with QSockets. #ifndef _WIN32 QProcess ping; ping.start("ping", QStringList() << "-c 1" << m_sHostName); if(ping.waitForFinished(250) ) { while(ping.canReadLine()) { QString line = ping.readLine(); if(line.contains("time=")) { int iStart = line

QHttpMultiPart: post files to PHP script

我的梦境 提交于 2019-12-03 08:30:40
I am working in Qt 5 and struggling with a multipart upload. My script is as close to the docs as possible: QUrl testUrl("http://localhost/upload/test.php"); QNetworkRequest request(testUrl); QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); QString preview_path = "C:/preview.jpg"; QHttpPart previewPathPart; previewPathPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"preview_path\"")); previewPathPart.setBody(preview_path.toLatin1()); QHttpPart previewFilePart; previewFilePart.setHeader(QNetworkRequest::ContentTypeHeader,

Downloading a file with Qt?

こ雲淡風輕ζ 提交于 2019-12-02 07:24:32
I am trying to figure out a way for my Qt browser app can download a word document from our web app. The web app is written in ExtJS, when (in a browser such as Chrome) a user clicks the "Download report" button a javascript event listener detects that click and opens a 0px0px iframe and the file downloads. I'm not sure how to replicate this browser feature in Qt? When I click on the link I get a network reply of "Operation canceled" 5 ? What class/method would be best to retrieve these files? to download a file you need : a QNetworkAccessManager in this case http . a QFile in this case file .

Obtaining MAC address on windows in Qt

痞子三分冷 提交于 2019-12-01 15:17:54
I am attempting to obtain mac address on windows xp using this code: QString getMacAddress() { QString macaddress="??:??:??:??:??:??"; #ifdef Q_WS_WIN PIP_ADAPTER_INFO pinfo=NULL; unsigned long len=0; unsigned long nError; if (pinfo!=NULL) delete (pinfo); nError = GetAdaptersInfo(pinfo,&len); //Have to do it 2 times? if(nError != 0) { pinfo= (PIP_ADAPTER_INFO)malloc(len); nError = GetAdaptersInfo(pinfo,&len); } if(nError == 0) macaddress.sprintf("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address[0],pinfo->Address[1],pinfo->Address[2],pinfo->Address[3],pinfo->Address[4],pinfo->Address[5]); #endif

Obtaining MAC address on windows in Qt

ⅰ亾dé卋堺 提交于 2019-12-01 14:15:19
问题 I am attempting to obtain mac address on windows xp using this code: QString getMacAddress() { QString macaddress="??:??:??:??:??:??"; #ifdef Q_WS_WIN PIP_ADAPTER_INFO pinfo=NULL; unsigned long len=0; unsigned long nError; if (pinfo!=NULL) delete (pinfo); nError = GetAdaptersInfo(pinfo,&len); //Have to do it 2 times? if(nError != 0) { pinfo= (PIP_ADAPTER_INFO)malloc(len); nError = GetAdaptersInfo(pinfo,&len); } if(nError == 0) macaddress.sprintf("%02X:%02X:%02X:%02X:%02X:%02X",pinfo->Address

Qt Download File - QNetworkAccessManager, not getting data

99封情书 提交于 2019-11-29 15:43:26
I'm trying to have my application download a file from a URL, typically an EXE or a Jar, not that this should change much though. I have this all running in a thread, but I don't think that will make a difference (if it does let me know). So Do_Download is my function that creates the manager, sets the URL and request, and performs get. I then try to connect the finished signal to the slot the will write the file. void DownloadManager::Do_Download() { QNetworkAccessManager *netManager = new QNetworkAccessManager(this); QUrl url(install_mirror); //istall_mirror is the URL provided by user

Error while using QTcpSocket

走远了吗. 提交于 2019-11-28 11:07:42
问题 I am creating a (very basic) MJPG server to show webcam data on a browser. I have partly managed to do it so far. Here is my code: TcpServer::TcpServer(QObject *parent) : QObject(parent) { server = new QTcpServer(this); // whenever a user connects, it will emit signal connect(server, SIGNAL(newConnection()), this, SLOT(newConnection())); if (!server->listen(QHostAddress::Any, 9999)) qDebug() << "Server could not start"; else qDebug() << "Server started!"; } ... void TcpServer::newConnection()

Make get request to web service, get json response and update GUI in Qt

穿精又带淫゛_ 提交于 2019-11-28 10:36:21
Trying to learn Web Services with Qt (using Qt Creator 4.1.0) and connecting data to the GUI . I have read several online examples (most notably: 1 , 2 and 3 ) but my low coding level along with the fact that I could not find full examples that were demonstrating my needs lead me here :). I have created a simple example so that contains all my shortcomings: make an HTTP get request to a (existing) web service every 30 seconds. The web service then responds by sending a json data object (see below for such a json example format) which we receive and parse . Then, the Qt will display all the

Qt Download File - QNetworkAccessManager, not getting data

与世无争的帅哥 提交于 2019-11-28 09:50:49
问题 I'm trying to have my application download a file from a URL, typically an EXE or a Jar, not that this should change much though. I have this all running in a thread, but I don't think that will make a difference (if it does let me know). So Do_Download is my function that creates the manager, sets the URL and request, and performs get. I then try to connect the finished signal to the slot the will write the file. void DownloadManager::Do_Download() { QNetworkAccessManager *netManager = new

Is there any way to building static Qt with static OpenSSL?

徘徊边缘 提交于 2019-11-27 09:25:34
Original question was slightly different but part of a more major question. I am trying to build Qt 5.2 as static with static OpenSSL on Windows. My final goal is to ship a single binary without the need to provide libeay32.dll and ssleay32.dll with it. However, it seems to me that this is impossible. I built static Qt with static openssl libs but it seems like Qt is outright ignoring the libs provided and always searches for DLLs. This answer also suggests that QtNetwork always searches for DLLs and ignores everything else but it also states that "two options are to compile OpenSSL into Qt ..