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. [Solved]Asynchronous and signal and slot
Forum Updated to NodeBB v4.3 + New Features

[Solved]Asynchronous and signal and slot

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.4k 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.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    @
    QNetworkReply *reply = manager->get(QUrl("xxx"));

    connect(reply, SIGNAL(finished()), this, SLOT(some_slot()) );
    @

    when I call manager->get, the QNetworkAccessManager will fetch the data from web
    And then I connect the signal to slot
    what if the reply already fetch all of the data before the connection establish?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2

      The only way any other code could be executed between those lines is when you have multiple threads and the scheduler stops the main thread right after the first line, executes some of the other thread, and returns back to execute the second line.

      However, if this is the case, Qt will use Queued Connections for signaling. So even if the other thread emits a signal in between those lines, the main thread will receive this signal in the next iteration of the event loop in the main thread, which comes after the function that contains those two lines.

      And if there are no other threads involved, you also don't need to worry. Because then it's impossible that any other code is executed in between the two lines anyway.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #3

        Thank you very much, don't know how Qt make this work
        I will treat it as some kind of "black magic" for now

        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