void SQ_GLWidget::keyPressEvent(QKeyEvent *e)
{
if(e->key() == Qt::Key_Space)
sqWStack->emitPreviousSelected(); // activate
}
// some time later we return back in SQ_GLWidget class:
void SQ_GLWidget::emitShowImage(const QString &file)
{
File = file;
sqGLView->setCaption(File);
QTimer::singleShot(1, this, SLOT(slotShowImage()));
}
slotShowImage() - is a big function with a big cycle. For example, user pressed Space, and then pressed once more. If slotShowImage() already running, it should be interrupted and new image should be displayed.
Very nice example doesn't work:
SQ_GLThread *t = new SQ_GLThread;
void SQ_GLWidget::emitShowImage(const QString &file)
{
File = file;
sqGLView->setCaption(File);
if(t->running())
{
t->stop();
t->wait()
}
t->start();
}
, because slotShowImage() uses OpenGL functions, and cann't be threaded.
Any ideas ??