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. Before during and after...

Before during and after...

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

    Hi. Hope someone can help me with this.
    I know there are many articles out there explaining the sequence Slots and Signals are executed in, but this problem seems to be a bit different.

    My goal:
    To fully execute one set of commands before a while loop.
    Followed by a 10sec while loop during which I will have to repeat a second set of commands.
    Then execute a third set of commands.

    Problem:
    When I run the below code the delay works, but the phase1 and phase2 commands only execute after the delay.
    Why is this?

    @void MainWindow::on_StartBtn_clicked()
    {
    ui->status_label->setText("Phase1 commands started");

    //set of commands that need to run before while loop executes.
    
    QTime FutureTime = QTime::currentTime();
    FutureTime = FutureTime.addSecs(10);
    
    while (QTime::currentTime()<= TempTime)
    {
        ui->status_label->setText("Phase2 commands started");
    

    //Set of commands that need to repeat during the while loop
    }

    ui->status_label->setText("Phase3 commands started");
    
    //set of things that need to execute after while loop is done
    

    }@

    1 Reply Last reply
    0
    • G Offline
      G Offline
      giesbert
      wrote on last edited by
      #2

      are you sure that the co0mmands are executed late and not just the ui is not updated?
      Changing the text of a label does not directly repaint, it only triggers an update which is done in one of the next repaints. If you want to see imediate results, call ui->status_label->repaint().

      Nokia Certified Qt Specialist.
      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

      1 Reply Last reply
      0
      • A Offline
        A Offline
        achmed
        wrote on last edited by
        #3

        Thanks... You are on the ball. It was just the UI not updating. ;)

        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