Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Make QNAM not sent any new request, until the last requests' response has arrived.

Make QNAM not sent any new request, until the last requests' response has arrived.

Scheduled Pinned Locked Moved Unsolved Qt WebKit
5 Posts 4 Posters 780 Views
  • 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.
  • R Offline
    R Offline
    Rizwan94
    wrote on last edited by
    #1

    Hello,
    I am working on a Qt application using C++.
    I need to make http requests through my application, so i am using QNetworkAccessManager for the REST api calls.

    I need the asynchrounous behavior which the QNAM provides, but there is one use case in which i would like the QNAM to wait and not sent any new requests, until the last requests has returned.

    How do i acheive that?

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

      Hi,

      Can you explain how you define that the QNAM has to start waiting ?

      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
      • R Rizwan94

        Hello,
        I am working on a Qt application using C++.
        I need to make http requests through my application, so i am using QNetworkAccessManager for the REST api calls.

        I need the asynchrounous behavior which the QNAM provides, but there is one use case in which i would like the QNAM to wait and not sent any new requests, until the last requests has returned.

        How do i acheive that?

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @Rizwan94 said in Make QNAM not sent any new request, until the last requests' response has arrived.:

        i would like the QNAM to wait and not sent any new requests, until the last requests has returned.

        Each time you get a completed reply, the QNetworkReply object emits a finished() signal.

        Make your app listen for these finished() signals. Do not call QNetworkAccessManager::get() or post() until you have received the last signal.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        R 1 Reply Last reply
        2
        • JKSHJ JKSH

          @Rizwan94 said in Make QNAM not sent any new request, until the last requests' response has arrived.:

          i would like the QNAM to wait and not sent any new requests, until the last requests has returned.

          Each time you get a completed reply, the QNetworkReply object emits a finished() signal.

          Make your app listen for these finished() signals. Do not call QNetworkAccessManager::get() or post() until you have received the last signal.

          R Offline
          R Offline
          Rizwan94
          wrote on last edited by
          #4

          @JKSH Thank you for your response.

          I am currently connecting to the replyFinished signal of the QNAM but not the QNetworkReply.
          I will try if your suggested approach works fine with replyFinished of QNAM.

          Also, I am concerned if the UI hangs when I am not processing any further requests.
          Example :
          When button1 is clicked, I send the request1 and wait for the response. What if the user in meantime clicks on the button2 which does another request2 ? Won't the UI hang?

          Am sorry for adding multiple questions in this comment.
          Let me know if you need further info

          jsulmJ 1 Reply Last reply
          0
          • R Rizwan94

            @JKSH Thank you for your response.

            I am currently connecting to the replyFinished signal of the QNAM but not the QNetworkReply.
            I will try if your suggested approach works fine with replyFinished of QNAM.

            Also, I am concerned if the UI hangs when I am not processing any further requests.
            Example :
            When button1 is clicked, I send the request1 and wait for the response. What if the user in meantime clicks on the button2 which does another request2 ? Won't the UI hang?

            Am sorry for adding multiple questions in this comment.
            Let me know if you need further info

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Rizwan94 said in Make QNAM not sent any new request, until the last requests' response has arrived.:

            I am concerned if the UI hangs

            If you're using signals/slots then the UI will not hang (do not wait "actively" using any "wait*" methods or loops).

            "When button1 is clicked, I send the request1 and wait for the response" - how do you "wait"? With signals/slots you do not have to wait and block anything.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            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