[Qt-interest] Create a new GUI Thread

Andreas Pakulat apaku at gmx.de
Wed Feb 11 07:37:31 CET 2009


On 11.02.09 02:04:52, Luis Roberto P. Paula wrote:
> My application has two windows. The first is the main window and the second
> is started after the click of a button.
> 
> When the button is clicked, a new thread is started. The problem is that I
> can't start/show a QDialog in this new thread.

You can't do any GUI operation outside of the thread that created
QApplication and runs QApplication::exec().

> I'm doing this because I need to have a different event loop for the QDialog
> window.

So you want two event loops that run in parallel, not one loop that blocks
the other (which can be done with QDialog::exec())? May I ask why?

As to how to do that: The only way is putting the code that needs to run in
the second event loop into a separate application and then use IPC (like
QDBus) to communicate between the two processes.

Andreas

-- 
You will have long and healthy life.



More information about the Qt-interest-old mailing list