[Qt-interest] please help me with this problem
Yifei Li
yifli at mtu.edu
Tue Dec 8 03:31:53 CET 2009
I agree. The message is displayed by the gui thread, and it is my work threads that sleeps.
Instead of displaying the messages in QGraphicsScene, I tried to output the messages to a terminal and that worked fine:
sleep(2);
cout << "hello 1" << endl;
sleep(2);
cout << "hello 2" << endl;
sleep(2);
cout << "hello 3" << endl;
...
Yifei
----- Original Message -----
From: "Glenn Hughes" <ghughes02138 at gmail.com>
To: qt-interest at trolltech.com
Sent: Monday, December 7, 2009 8:58:29 PM GMT -05:00 US/Canada Eastern
Subject: Re: [Qt-interest] please help me with this problem
Sleep should never block... from the man page:
"The sleep() function suspends execution of the calling thread until
either seconds seconds have elapsed or a signal is delivered to the
thread and its action is to invoke a signal-catching function or to ter-
minate the thread or process."
In other words, other threads can run while one thread is sleeping.
It might however have something to do with the way that cross-thread
signals are delivered.
Its an interesting question...
> I think your problem is that sleep() blocks. That means, the
> application actually "hangs" for 2 seconds between each sleep() with no
> chance to update the display.
>
> You should use timers instead of sleep(). See
> http://doc.trolltech.com/4.6/qtimer.html#details on how to emit signals
> with a time delay or periodically.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list