[Development] Trigger Qt event loop from external message loop

Roland Winklmeier roland.m.winklmeier at gmail.com
Fri Dec 20 10:06:25 CET 2013


Unfortunately Mac is (additional to Win and Linux) a target OS, so if this
is not working on that I have to find another way to do it. I found
QMacNativeWidget which looks promising and looking into its implementation
I'm wondering how Qt's event loop is triggered?

With Qt4 I also used QWinWidget alot, which worked fine in Qt4 but is
broken in Qt5. QWinWidget created a QApplication and was registering a
message monitor (with SetWindowsHookEx) and triggered the event loop in the
callback by qApp->sendPostedEvents().


2013/12/20 Sze Howe Koh <szehowe.koh at gmail.com>

> On 20 December 2013 04:52, Kuba Ober <kuba at mareimbrium.org> wrote:
> > Is this supported on all platforms now? IIRC it did not work OS X last
> time I tried, but yes,
> > it did work great on Windows.
> >
> > — Kuba
>
> The Cocoa framework mandates that all GUI-related operations must be
> done in the first thread in a process [1]. That's why this technique
> cannot work on OS X. I believe it was possible with Carbon apps, but
> not Cocoa apps.
>
>
> Regards,
> Sze-Howe
>
> [1]
> http://www.cocoabuilder.com/archive/cocoa/315103-why-is-the-threading-and-ui-updating-designed-to-be-done-only-on-main-thread.html
>
>
> > On Dec 14, 2013, at 3:25 PM, Roland Winklmeier <
> roland.m.winklmeier at gmail.com> wrote:
> >
> >> Thanks very much Olivier and Thiago!
> >> That works brilliant.
> >>
> >> No idea why I forgot that QThread must not be used. But its of course
> >> obvious. I made a quick setup with native threads (std::thread is
> >> unfortunately not supported by VC2010) and it works perfectly now.
> >>
> >> In case someone is interested:
> >> - - I added a additional shared library spawning a thread and links the
> >> actual plugin during runtime with LoadLibrary/dlopen. No Qt stuff in
> here.
> >> - - Second shared library creates QApplication object and runs its
> >> exec() loop.
> >>
> >> Cheers Roland
> >>
> >> Am 14.12.2013 19:23, schrieb Thiago Macieira:
> >>> On sábado, 14 de dezembro de 2013 12:42:32, Roland Winklmeier
> >>> wrote:
> >>>> n qthread_win.cpp QThreadPrivate::start -> void
> >>>> QThreadPrivate::createEventDispatcher(QThreadData *data) {
> >>>> QEventDispatcherWin32 *theEventDispatcher = new
> >>>> QEventDispatcherWin32;
> >>>> data->eventDispatcher.storeRelease(theEventDispatcher);
> >>>> theEventDispatcher->startingUp(); }
> >>>
> >>> You must not use QThread.
> >>>
> >>> You need to start your thread before using any QObject-derived
> >>> classes. Once you're there, instantiate the QApplication
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20131220/0e488794/attachment.html>


More information about the Development mailing list