saifulkhan
1st February 2013, 00:43
8663
Dear Qt Community,
Request your help. We show a random character (A, B, C, ...) in a scene. When the user presses the key then a black window appears and stays for 200 msec. Thereafter another character appears in the screen and the user can make selection by pressing a key again. This process keeps repeating.
If I use the following code to sleep, then the GUI freezes. We can not see the black window.
class Sleep : 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);
}
};
The following code does not freeze the GUI, but it keeps taking the events when the window is blank. But when the window is blank we do not want any keypress event to be processed.
QTime dieTime = QTime::currentTime().addSecs(2);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEve nts, 100);
Dear Qt Community,
Request your help. We show a random character (A, B, C, ...) in a scene. When the user presses the key then a black window appears and stays for 200 msec. Thereafter another character appears in the screen and the user can make selection by pressing a key again. This process keeps repeating.
If I use the following code to sleep, then the GUI freezes. We can not see the black window.
class Sleep : 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);
}
};
The following code does not freeze the GUI, but it keeps taking the events when the window is blank. But when the window is blank we do not want any keypress event to be processed.
QTime dieTime = QTime::currentTime().addSecs(2);
while( QTime::currentTime() < dieTime )
QCoreApplication::processEvents(QEventLoop::AllEve nts, 100);