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
Forum Updated to NodeBB v4.3 + New Features

Wait for execution

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.1k 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 12 Oct 2012, 07:33 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
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 12 Oct 2012, 07:47 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

      1/2

      12 Oct 2012, 07:33

      • Login

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