[PyQt] QMetaObject.invokeMethod with C++/QML type

Alexander Rössler alexander at roessler.systems
Fri Sep 21 22:10:37 BST 2018


I want to call a C++/QML method from PyQt via QMetaObject.invokeMethod like so:

return_val = QMetaObject.invokeMethod(
self._graph, "insertNode", Qt.DirectConnection, Q_RETURN_ARG(QVariant)
)

The method I call is https://github.com/cneben/QuickQanava/blob/master/src/qanGraph.h#L335 which returns a custom QML registered QObject based type.
However, when I try to invoke the method Q_RETURN_ARG it fails.
FATAL ERROR: An unexpected error occurred:
QMetaObject.invokeMethod() call failed

Without specifying a return type, invoking the method works. Since it's a type registered in the Qt meta object system, I expected that QVariant or QObject would work as return types.
Any ideas why this doesn't work and how I could use the returned QObject without "siping" the whole library?
Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180921/a89a9d19/attachment-0001.html>


More information about the PyQt mailing list