[Qt-interest] ASSERT: "qApp && qApp->thread() == QThread::currentThread"

Karol Krizka kkrizka at gmail.com
Tue May 26 16:08:15 CEST 2009


On Tue, 2009-05-26 at 15:57 +0200, Wasilios Goutas wrote:
> Hi,
> 
> I'm new to QT and have a basic question.
> I use the ACE framework and wrote some libs wich analyses files and send 
> vektor informations wich I try to visualize using OpenGL inside QT.
> The libraries contains so called tasks which creates diferent threads.
> One of this threads inherits  from QGLWidget and implements the 
> paintGL() function.
> 
> By now, I created the QApplication instance in the main thread, the 
> QMainWindow and its GLWidget instances inside my visualization library 
> wich sends OpenGL command in a separete worker thread.
> This results in the assertion
> ASSERT: "qApp && qApp->thread() == QThread::currentThread()" in file 
> kernel/qapplication_win.cpp, line 902
> when my paintGL() function is called.
> 
> Also when I instantiated the QMainWindow object in the main thread I get 
> this assertion.
> It seems to me, that the thread initializd the QApplication instance has 
> also to be the thread with owns the instance of the used widgets.
> Is this right?
> 
I believe that statement is right. You need to perform all of your GUI
operations (as related to drawing) in the main thread. Drawing is done
in the thread where the object was created.

I read somewhere (some old Qt Quarterly) that it was possible to do the
OpenGL rendering in a separate thread, but that required a lot of extra
work so I just forgot about it. Plus the example was with Qt3.

--
Cheers,
Karol Krizka
http://www.krizka.net




More information about the Qt-interest-old mailing list