Qt-interest Archive, April 2007
Re: QApplication::sleep() missing
Message 1 in thread
> as I said for Qt3, a sleep function for QApplication would be really nice.
> Sometimes it is really needed to force the whole application to sleep.
class SleepyThread : public QThread
{
public:
void msleep( int n ) { QThread::msleep( n ); }
void usleep( int n ) { QThread::usleep( n ); }
void sleep( int n ) { QThread::sleep( n ); }
};
static_cast< SleepyThread* >( QThread::currentThread() )->msleep( 100 );
--
[ signature omitted ]
Message 2 in thread
Hi
Please, do consider using other means than sleeping. Sleeping in a GUI
application is a bad idea because it will block the event loop of the
application and make it non-responsive. One straightforward approach
would be use QTimer::singleShot() to make a delayed call and still let
the application process it's events meanwhile.
--
[ signature omitted ]