Questions tagged [qtnetwork]

The QtNetwork module provides classes to make network programming easier and portable. Qt Network provides a set of APIs for programming applications that use TCP/IP. Operations such as requests, cookies, and sending data over HTTP are handled by various C++ classes.

The Qt Network module offers classes that allow you to write TCP/IP clients and servers. It offers lower-level classes such as QTcpSocket, QTcpServer and QUdpSocket that represent low-level network concepts, and high-level classes such as QNetworkRequest, QNetworkReply and QNetworkAccessManager to perform network operations using common protocols. It also offers classes such as QNetworkConfiguration, QNetworkConfigurationManager and QNetworkSession that implement bearer management.

To use Qt Network classes, add this directive into the C++ files:

#include <QtNetwork>

To link against the module, add this line to your qmake .pro file:

QT += network

The official Qt documentation can be found here for Qt 4.8 and here for Qt 5.

203 questions
16
votes
4 answers

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

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…
cen
  • 2,673
  • 2
  • 24
  • 51
13
votes
4 answers

Is it possible to deploy a Qt Quick application without Qt Network on OS X?

I have a Qt Quick application using the following modules QT = core gui qml quick widgets \ core-private gui-private \ multimedia printsupport` which I deploy on OS X. Now my main binary as well as a lot of Qt Qtick plugins show a…
Simon Warta
  • 8,469
  • 4
  • 32
  • 62
12
votes
2 answers

Obtaining MAC address on windows in Qt

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…
Gandalf
  • 11,766
  • 26
  • 82
  • 146
12
votes
2 answers

How to get the hostname using Qt?

How to get the host name of my desktop PC? Like this, to get system information for Symbian OS: http://developer.nokia.com/community/wiki/Get_device_information_using_Qt
Chawki Messaoudi
  • 519
  • 1
  • 4
  • 17
10
votes
4 answers

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

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…
dgrat
  • 2,036
  • 4
  • 19
  • 39
8
votes
2 answers

QEventLoop proper usage

I have doubts how should I use QEventLoop. I have 2 pieces of code, both of them work for me (get web resource downloaded). First one: QNetworkAccessManager *manager = new QNetworkAccessManager( this ); QNetworkRequest…
Bartek Boczar
  • 227
  • 1
  • 3
  • 6
8
votes
1 answer

Accessing QNetworkRequest data before it's sent

Is there any way to see the data that will be sent (or has been sent) during (or after) a call to QNetworkAccessManager::post(QNetworkRequest,QByteArray) on the client side? In other words, I would like to see the raw HTTP request in it's…
user336063
8
votes
2 answers

Qt synchronous QNetworkAccessManager get

What's the proper way to do a synchronous QNetworkAccessManager::get ? The qt wiki offers an approach, but states "it is not recommended to use this in real applications." The mailinglist offers a similar solution to the wiki.
Eugene
  • 9,015
  • 18
  • 58
  • 86
7
votes
1 answer

IP Aliasing with QWebView (Qt / C++)

Let’s see if you can shed some light on my problem. [C++ with Qt 5.2, using Qt Creator] Situation: I’ve got a PC with several local IP addresses assigned to the same interface (IP Aliases). The router has different configurations regarding…
lgvidal
  • 259
  • 2
  • 10
6
votes
5 answers

Problem in developing FTPClient using Qt

I am trying to implement FTPClient in using QT Network . How can i handle exceptional cases like during downloading network cable is unplugged , not internet connection gone etc.. ? How can my FTPClient can come to know about such event and is there…
Ashish
  • 7,621
  • 11
  • 48
  • 89
6
votes
1 answer

QHttpMultiPart: post files to PHP script

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…
flatface
  • 186
  • 1
  • 7
6
votes
3 answers

Webpage returning HTTP 406 error only when connecting from Qt

I have a test page setup at http://mlecturedownload.com/test-qt.php that has the following code:
gsingh2011
  • 11,032
  • 21
  • 93
  • 138
5
votes
3 answers

can time.sleep(secs) suspend QNetworkAccessManager does request asynchronously?

QNetworkAccessManager can do requests asynchronously, and time.sleep(secs) can suspend the execution for the given number of seconds. I was confused by the code below. Is t2 here always greater than 10 seconds? Without using time.sleep(secs) in the…
iMath
  • 1,954
  • 2
  • 29
  • 64
5
votes
1 answer

Qt: default connection timeout for QTcpSocket

Please advise how can I setup default connection timeout without using blocking waitForConnected() method? I noticed that socket emit error signal (QAbstractSocket::SocketTimeoutError) after about 60 seconds that I can handle as a timeout, but can…
user3948829
5
votes
0 answers

How to obtain the server QSslCertificate from QNetworkAccessManager and QNetworkRequest?

I am sending requests via QNetworkAccessManager::createRequest(Operation, QNetworkRequest, outgoingData). I'm required to verify that the fingerprint of the SSL-Certificate is the one I expect. Unfortunately the resulting QNetworkReply returns a…
Senči
  • 871
  • 2
  • 10
  • 25
1
2 3
13 14