PDA

View Full Version : Problem with code (probably repaintinng label)



hakermania
8th January 2011, 10:39
Hello all, i would like to tell me what's wrong with this code


for(int a=9;a>=0;a--)
{
ui->label->setText((QString)a);
ui->label->repaint();
sleep(1);
}


where sleep(const int) is the function from the iostream library and waits const int seconds till the next step.
The label isn't repainted :/
So, actually it is a label that must change its value every second. Thanks :)

Added after 39 minutes:

For anybody following this thread, the solution is to use a QTimer :)

Lykurg
8th January 2011, 11:29
i would like to tell me what's wrong
nice :D

By the way: if there is no special reason always use update() not repaint(). Further a follow up lecture: http://doc.trolltech.org/qq/qq27-responsive-guis.html

wysota
8th January 2011, 13:58
I would say that casting int to QString is the problem.