PDA

View Full Version : Display qlabel text immediately



Qqt
4th February 2012, 12:31
Hello,

I have a push button and a label in a dialog. When the push button is clicked, the program will start to do some calculation. The label is designed to display the status, such as initialization, in progress and completes, but the label is NOT updated immediately after it reaches settext(), I even tried to call repaint(), but still no luck. In the dialog, the label is always blank until coming to the end, then "Completes" is displayed.

Can anyone help point out where is wrong and how to fix this? Thanks.

Here is the code:


void Test::on_start_Button_clicked()
{
ui->label_status->setText("Reading data from file ...");
ui->label_status->repaint();

Do_1(); // function to do something

ui->label_status->setText("Action in progress ...");
ui->label_status->repaint();

Do_2(); // function to do something

ui->label_status->setText("Completes.");
ui->label_status->repaint();

wysota
4th February 2012, 13:20
Keeping the GUI Responsive

Qqt
5th February 2012, 04:34
Thanks for the help, I got my gui working based on your suggestion.