Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing invokeMethod function for QMetaObject #130

Open
melvyn2 opened this issue May 6, 2023 · 2 comments
Open

missing invokeMethod function for QMetaObject #130

melvyn2 opened this issue May 6, 2023 · 2 comments

Comments

@melvyn2
Copy link

melvyn2 commented May 6, 2023

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?

@Riateche
Copy link
Member

Riateche commented May 9, 2023

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.

@melvyn2
Copy link
Author

melvyn2 commented May 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants