I am having trouble using the signals correctly in my PySide python Qt program. I want to emit a signal that takes one argument of a custom python type. documentation says
Signals can be defined using the QtCore.signal () class. Python types and C types can be passed as parameters to it.
So, I tried the following:
from PySide import QtCore from PySide.QtCore import QObject class Foo: pass class Bar(QObject): sig = QtCore.Signal(Foo) def baz(self): foo = Foo() self.sig.emit(foo) bar = Bar() bar.baz()
But get the following error:
Traceback (most recent call last): File "test.py", line 15, in <module> bar.baz() File "test.py", line 12, in baz self.sig.emit(foo) TypeError: sig() only accepts 0 arguments, 1 given!
If instead I get the Foo class from QObject, the program starts without errors. But should I not pass my custom type as an argument to the signal, even if this type cannot be obtained from QObject?
This is with python 2.7.2 and PySide 1.0.4 on Windows 7.
source share