[Qt-interest] problem with sleep

Pascal Patry iscy at invalidip.com
Tue Jun 23 21:31:41 CEST 2009


On Tuesday 23 June 2009 15:25:48 mierdatutis mi wrote:
> Hi,
>
> I try have program that when I do click in a QListWidget puts in a
> QTextBrowser some text, then sleeps X seconds and then put other text but
> it doesn't works. The first text that I put ( ---DESCARGANDO SINOPSIS ---)
> never appears in the object Qtextbrowser.
>
> Any help?
>
>
>
>
> Any help?
>
>  To sleep:
>
>
> class I : public QThread
>
> {
>
> public:
>
> static void sleep(unsigned long secs) {
>
> QThread::sleep(secs);
>
> }
>
> static void msleep(unsigned long msecs) {
>
> QThread::msleep(msecs);
>
> }
>
> static void usleep(unsigned long usecs) {
>
> QThread::usleep(usecs);
>
> }
>
> };
>
>
> To put the text I do:
>
>
> texto->setHtml(" ---DESCARGANDO SINOPSIS ---");
>
> I::sleep(3);
> texto->setHtml(" ---acabado tiempo DESCARGANDO SINOPSIS ---");

1. You seems to be blocking the event loop, so nothing will get painted on the 
screen. You should not be doing sleep but instead, you should rely on a 
'QTimer' to append the rest of the text.
2. 'setHtml()' resets everything, it doesn't only append things together.
3. 'setHtml()' is usually for html content, "---" is not a valid html tag.




More information about the Qt-interest-old mailing list