[Interest] QApplication in worker thread
Thiago Macieira
thiago.macieira at intel.com
Mon Aug 27 20:01:47 CEST 2018
On Monday, 27 August 2018 10:29:14 PDT Ramakanth Kesireddy wrote:
> > It's not recommended. It's required. The QCoreApplication object must be
> > created in the same thread as the thread that created the first QObject.
> > Usually. QCoreApplication is the first QObject anyway.
> > Inside Qt, that thread is understood as "the main thread" or "the GUI
> > thread".
> > But it need not be the same thread that main() was run on. Just make sure
> > that
> > no other QObject was created before.
>
> GUI is run in a separate thread instead of main thread of UI app process.
> The QCoreApplication object is
> created in the same worker thread that created the first QObject. Do you
> foresee any issues with the same?
As I said, for Qt's purposes, the main thread and the GUI thread are the same
thread and are the thread that created the first QObject. How that thread was
started is irrelevant.
> Is there any API to wait on the eventloop till it returns zero so that
> eventloop is exited normally?
There's no need to wait, since everything is happening in the same thread. The
event loop is started by the exec() function in QCoreApplication, QThread or
QEventLoop. Once the event loop exits, that function returns and the next line
in the function is executed.
If you started that thread through some non-Qt means, just wait for the thread
to exit.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Interest
mailing list