[Interest] QApplication in worker thread

Ramakanth Kesireddy rama.kesi at gmail.com
Mon Aug 27 20:23:37 CEST 2018


On Mon 27 Aug, 2018, 23:32 Thiago Macieira, <thiago.macieira at intel.com>
wrote:

> 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.
>

Thanks a lot for your response. I started the thread through some non-qt
means(using pthread)..Before terminating the thread, would like to ensure
eventloop is exited normally. But when qApp-quit() would take time before
which thread is deleted.

Is there any means that thread is deleted only after qt eventloop is exited
normally?

> --
> Thiago Macieira - thiago.macieira (AT) intel.com
>   Software Architect - Intel Open Source Technology Center
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20180827/af9467c8/attachment.html>


More information about the Interest mailing list