Results 1 to 2 of 2

Thread: QLabel::setText() how to

  1. #1
    Join Date
    Feb 2006
    Posts
    25
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QLabel::setText() how to

    Hello,

    I'm trying to run certain steps in my app and for every step I try to update a "status" QLabel with setText(). This keeps the text of the first step and changes until the last step. The text of all steps in between are never shown. here is a code snippet.

    Qt Code:
    1. QLabel *lStatus = new QLabel(tr("Starting procedure...."));
    2.  
    3. //create Database
    4. lStatus->clear();
    5. lStatus->setText("Creating database");
    6. createDatabase();
    7.  
    8. //apply settings
    9. lStatus->clear();
    10. lStatus->setText("Applying settings...");
    11. appSettings();
    12.  
    13. //update logfile
    14. lStatus->clear();
    15. lStatus->setText("update log file...");
    16. updateLog();
    17.  
    18. //Config Finished
    19. lStatus->clear();
    20. lStatus->setText("Configuration Finished");
    To copy to clipboard, switch view to plain text mode 

    Thanks in advanced.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QLabel::setText() how to

    You will have to let the application process it's events every once in a while to get the label updated. The most simple way to get it working is to add the line below in between each stage:
    Qt Code:
    1. QApplication::processEvents();
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    JediSpam (19th September 2011)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.