Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QEventLoop not finishing under Windows 7
Qt 6.11 is out! See what's new in the release blog

QEventLoop not finishing under Windows 7

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi,
    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:
    @box.setText("before loop");
    box.exec();
    QEventLoop loop;
    QNetworkReply *network_reply = manager->post(request,postData);
    QObject::connect(network_reply, SIGNAL(readyRead()), &loop, SLOT(quit()));
    loop.exec();
    box.setText("after loop");
    box.exec();@

    So The Problem is that it never reaches "after loop".

    Pls help me out.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      When you say it doesn't work with your static build, do you mean outside Qt Creator or also inside Qt Creator ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        outside!
        Im Running a Windows 7 64bit machine,
        compiled with mingw 32 bit.
        Perhaps it has to do something with threads?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alexisdm
          wrote on last edited by
          #4

          Hi,

          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.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            @alexisdm

            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.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ckakman
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved