ritual icon indicating copy to clipboard operation
ritual copied to clipboard

missing `invokeMethod` function for `QMetaObject`

Open melvyn2 opened this issue 2 years ago • 2 comments

https://doc.qt.io/qt-5/qmetaobject.html#invokeMethod I need to call invokeMethod from a non-GUI thread to trigger an object's slot in the GUI thread. The recommended method seems to be to use that object's meta-object invokeMethod function. However I cannot find this method in the qt_core bindings. What is missing for its implementation?

melvyn2 avatar May 06 '23 05:05 melvyn2

We're missing support for the QGenericArgument type, which is constructed in C++ using the Q_ARG macro. It's possible to add support for it for a finite set of types, but it hasn't been done yet.

As a workaround, you can use a queued signal-slot connection (see Signals and Slots Across Threads). When using a queued connection, Qt will automatically invoke slots in the receiver's thread. You can use a signal wrapper type provided by rust-qt to create a sender object.

Riateche avatar May 09 '23 13:05 Riateche

I was aware of using queued connections but I hadn't found the signal wrapper types. That solves my problem, thank you.

I'll leave the issue open in case it is eventually decided to implement invokeMethod.

melvyn2 avatar May 10 '23 00:05 melvyn2