PySide2 QMetaObject.invokeMethod() how to ?
-
@Dariusz Like
QMetaObject.invokeMethod(...)
?
https://doc.qt.io/qtforpython/PySide2/QtCore/QMetaObject.html -
@Dariusz said in PySide2 QMetaObject.invokeMethod() how to ?:
Because all I get is lots of error I'm afraid
Which are?
-
TypeError: 'PySide2.QtCore.QMetaObject.invokeMethod' called with wrong argument types: PySide2.QtCore.QMetaObject.invokeMethod(QApplication, function, ConnectionType) Supported signatures: PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...) PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericReturnArgument, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...) PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.Qt.ConnectionType, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...) PySide2.QtCore.QMetaObject.invokeMethod(PySide2.QtCore.QObject, bytes, PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ..., PySide2.QtCore.QGenericArgument = ...)
:- )
-
@jsulm Well as the example in 1st post shows, I was creating a function in c++ to be called. I want the same to do in python. Simply put, I want to create temporary function that gets send to qapplication from 3rd party thread to be executed inside qt event loop.
-
@Dariusz If you check the PySide documentation you will see that there is no overload taking a lambda or any function/method. There are only overloads accepting strings containing method name. So, it seems not possible with PySide.
But instead of using QApplication instance you could create your own class with methods you want to call using invokeMethod.