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. Wait for execution
Qt 6.11 is out! See what's new in the release blog

Wait for execution

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

    Hi All,

    I have a for loop in my GUI thread which sets some command but from one command to the next my loop should have to wait the answer from a serial device before going on. What is the right method to pause the for execution while the code is answering and receiving from the serial device?

    My pseudo code is:

    @ for i=0 to 1000
    set message_1
    set message_2

                        send command to the serial device
                        wait for answer
    
                        update tablewidget
                   go to next@
    
    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Please reformat this pseudocode and wrap it in '@' tags.

      It's generally considered better to use the event loop together with signals and slots, rather that waiting explicitly. But, if you insist, this piece of code should do the work:
      @
      forever {
      if (isAnswer == true)
      break;
      else
      qApp->processEvents();
      }
      @

      (Z(:^

      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