[Interest] Using QObject in different thread as the target of Connections
Elvis Stansvik
elvstone at gmail.com
Wed May 11 07:50:49 CEST 2016
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.
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
More information about the Interest
mailing list