PDA

View Full Version : QLabel::setText() how to



freak
30th October 2006, 17:14
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.



QLabel *lStatus = new QLabel(tr("Starting procedure...."));

//create Database
lStatus->clear();
lStatus->setText("Creating database");
createDatabase();

//apply settings
lStatus->clear();
lStatus->setText("Applying settings...");
appSettings();

//update logfile
lStatus->clear();
lStatus->setText("update log file...");
updateLog();

//Config Finished
lStatus->clear();
lStatus->setText("Configuration Finished");


Thanks in advanced.

jpn
30th October 2006, 17:19
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:


QApplication::processEvents();