I want to use QMetaObject::invokeMethod to call a method of an object (later it will run in another thread and then invokeMethod comes in handy). I use the Qt 4.8 bindings of PySide 1.2.1 on Python 3.3. The full example is:
from PySide import QtCore
class Tester(QtCore.QObject):
def __init__(self):
super().__init__()
def beep(self):
print('beep')
if __name__ == '__main__':
t = Tester()
QtCore.QMetaObject.invokeMethod(t, 'beep', QtCore.Qt.AutoConnection)
And the output is:
QMetaObject::invokeMethod: No such method Tester::beep()
while I expected beep
. The method was not invoked.
So what's wrong? It seems so simple that I cannot find the error.
edit: I got it to work using the `@QtCore.Slot' decoration on the method. Thanks to the comment and the answer.