Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QEventLoop not finishing under Windows 7
For a API call i created a Network POST call returning the Answer from the server into a QNetworkReply.
Because all this has to work in a single Function i decided to make use of the Event loop to catch the signal. However this only runs flawlessly under Linux. When I'm trying it under Windows 7 it sometimes works (only when im starting the programm via the IDE / When Im creating a Static build it never works).
To be able to catch the Problem i created two Message-Boxes before and after the loop to be able to "See a Debug-Output even when Im running my static realease Build".
My Code so far:
QNetworkReply *network_reply = manager->post(request,postData);
QObject::connect(network_reply, SIGNAL(readyRead()), &loop, SLOT(quit()));
So The Problem is that it never reaches "after loop".
Pls help me out.
When you say it doesn't work with your static build, do you mean outside Qt Creator or also inside Qt Creator ?
Im Running a Windows 7 64bit machine,
compiled with mingw 32 bit.
Perhaps it has to do something with threads?
alexisdm last edited by
It might "simply" mean the POST request failed for Windows specific reasons (uac, firewall, missing openssl dll...), in that case the readyRead() signal would never be emitted.
Instead of readyRead(), you could use the finished() signal, which would also be emitted in case of an http error, and you should add a QTimer to be safe, because QNetworkAccessManager never times out a request by itself.
thx that works plenty :)
Regardless I have to find a Way to get things running under Windows too. I'll let you know when I figured out.
ckakman last edited by
You may also want to set a QTimer with a long enough timeout value and its timeout() signal connected to the QEventLoop's quit() slot so that the loop exists either due to network activity or due to the timeout.