Wait for execution



  • 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@

  • Moderators

    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();
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.