<div>I investigated a little bit more:</div><br><div>        meta = self._graph.metaObject()</div><div>        print(meta.methodCount(), meta.methodOffset())</div><div>        for i in range(meta.methodOffset(), meta.methodCount()):</div><div>            method = meta.method(i)</div><div>            print(method.methodSignature(), method.returnType(), QMetaType.typeName(method.returnType()))</div><br><div>Which showed me the Qt type</div><div>qan::Node*</div><br><div>trying</div><br><div>return_val = QMetaObject.invokeMethod(</div><div>            self._graph, "insertNode", Qt.DirectConnection, Q_RETURN_ARG('qan::Node*')</div><div>        )</div><br><div>I get a more descriptive error:</div><div>TypeError: C++ type 'qan::Node*' is not supported as a Q_RETURN_ARG() type</div><br><div>Which makes sense, since it's a C++ type. Are there any other ways to use the returned object from PyQt than to wrap the library with sip?</div><br><div>I already tried to wrap the library with sip, but I can't get it to work without causing segfaults. That's why I'm looking for simpler alternatives.</div><br><div class="gmail_quote_attribution">On Sep 21 2018, at 11:10 pm, Alexander Rössler <alexander@roessler.systems> wrote:</div><blockquote><br><div><div>I want to call a C++/QML method from PyQt via QMetaObject.invokeMethod like so:</div><br><div>return_val = QMetaObject.invokeMethod(</div><div>self._graph, "insertNode", Qt.DirectConnection, Q_RETURN_ARG(QVariant)</div><div>)</div><br><div>The method I call is <a href="https://github.com/cneben/QuickQanava/blob/master/src/qanGraph.h#L335" title="https://github.com/cneben/QuickQanava/blob/master/src/qanGraph.h#L335">https://github.com/cneben/QuickQanava/blob/master/src/qanGraph.h#L335</a> which returns a custom QML registered QObject based type.</div><br><div>However, when I try to invoke the method Q_RETURN_ARG it fails.</div><div>FATAL ERROR: An unexpected error occurred:</div><div>QMetaObject.invokeMethod() call failed</div><br><div>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.</div><br><div>Any ideas why this doesn't work and how I could use the returned QObject without "siping" the whole library?</div><br><div>Alex</div><div>_______________________________________________</div><div>PyQt mailing list PyQt@riverbankcomputing.com</div><div>https://www.riverbankcomputing.com/mailman/listinfo/pyqt</div></div></blockquote>