I am having trouble correctly using signals in my PySide python Qt program. I want to emit a signal that takes a single argument of a custom python type. The 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 derive the Foo class from QObject, the program runs without error. But shouldn't I be able to pass my custom type as an argument to the signal, even if that type does not derive from QObject?
This is with python 2.7.2 and PySide 1.0.4 on Windows 7.