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. Differentiating Between Multiple Signals Using One Slot

Differentiating Between Multiple Signals Using One Slot

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 636 Views 2 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.
  • A Offline
    A Offline
    Angelo DeLuca
    wrote on last edited by
    #1

    Okay, so I don't know if I'm having a brain fart and making this needlessly hard, or if what I'm proposing is the most efficient in my scenario (probably the first one).
    I am using the Google Drive API to copy three different templates into one folder, which, of course– means three HTTP requests. I have written a small API client library to try and make interacting with the API use less code. The issue is when I make multiple calls to the same function of the same instance of a class (my API library), and differentiating between the responses. Looking at the response data as a means of identification is possible, but it exudes inefficiency; it doesn't feel right. Now, I could take the route of creating multiple slot functions, and making a new request as soon as another completes– but that doesn't seem like a very modular, efficient, or clean solution either. Is there some multithreading technology that I should use?

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

      Hi and welcome to devnet,

      It looks like you want to process your requests in order so what about using a queue ? Each time one request completed you pop the next one.

      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
      • A Offline
        A Offline
        Angelo DeLuca
        wrote on last edited by Angelo DeLuca
        #3

        That sounds like a similar idea to what I had, but my goal is to try and make this process as quick as possible. Would there be some way to make these requests happen concurrently and have some signal be emitted when all have completed?

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

          If you are using QNetworkAccessManager you can have up to 6 parallel requests. The others will be queued.

          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
          2
          • A Offline
            A Offline
            Angelo DeLuca
            wrote on last edited by
            #5

            Oh, interesting! How would one handle the responses in such a circumstance?

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

              What do you need to do with the answers ?

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

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                What do you need to do with the answers ?

                A Offline
                A Offline
                Angelo DeLuca
                wrote on last edited by
                #7

                @SGaist I am making multiple POST requests to the same API endpoint, just with different data. Each request creates a document, and each response gives back this new document's ID, which is crucial. I need to send three of these requests concurrently, and get their responses so that I can parse each ID. I can do this with one slot, but I won't know the reply's respective document. Should I have a new QThread, and have a loop checking each QNetworkReply's "finished" status- which when all are complete, emit their combined responses to a single slot?

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

                  You could set that information as a dynamic property of your reply that way you do not need to special handling. All the information would be in one place.

                  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
                  1
                  • A Offline
                    A Offline
                    Angelo DeLuca
                    wrote on last edited by
                    #9

                    I think I figured it out. Thank you, I appreciate your time!

                    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