[Interest] Using QObject in different thread as the target of Connections

Elvis Stansvik elvstone at gmail.com
Mon May 16 18:19:37 CEST 2016


Den 11 maj 2016 7:50 fm skrev "Elvis Stansvik" <elvstone at gmail.com>:
>
> Hi all,
>
> Setting a QML engine root context property to a QObject instance that
> has been moved to a different thread and then attempting to connect to
> one of its signals with Connections on the QML side seems unsupported:
>
>      QQmlEngine: Illegal attempt to connect to Test(0x22b66c0) that is
> in a different thread than the QML engine
>
> I'm just wondering why this is not allowed, since on the C++ side (or
> well, Python in my case), I can conveniently use the Qt signal/slot
> mechanism to communicate with another thread.

Noone knows the rationale?

Elvis

>
> Direct calls to member functions on it would not be supported of
> course, or using it in property bindings (which would result in the
> former), but why can't I connect to its signals, or connect signals to
> its slots?
>
> Does this mean that if I want to expose an object that has been moved
> to another thread to QML, I must create a proxy object on the
> C++/Python side, living in the main thread, which forwards its
> signals, and set that as a context property instead?
>
> Thanks for any answers!
>
> Elvis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160516/a8fd2c98/attachment.html>


More information about the Interest mailing list