cascoin
6th June 2011, 12:53
Hello everybody,
I do have a problem with the signal/slot stuff.....
class Test(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.connect(self, SIGNAL('send(int)'), self, SLOT('receiver(int)'))
def send(self, value):
self.emit(SIGNAL('send(int)'), value)
@pyqtSignature('receiver(int)')
def receiver(self, value):
print value
def main():
test = Test()
test.send(12345)
app = QtGui.QApplication(sys.argv)
Start = main()
sys.exit(app.exec_())
Here you can see my very simple code... I have a class called Test.... I want that this class emits a signal and the same class receives this signal.
As the code is written above everything is fine....
Now I want to emit not a integer variable. I want to emit and receive a customer class... I simply changed int everywhere to my classes name and tried to run this code...
Here is how I did it....my customer class and the new code...
from PyQt4.QtCore import *
from PyQt4 import QtGui
import sys
class Student:
def __init__(self, name, Studium, Nr):
self.name = name
self.Fach = Studium
self.Matrikel = Nr
class Test(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.connect(self, SIGNAL('send(Student)'), self, SLOT('receiver(Student)'))
def send(self, value):
self.emit(SIGNAL('send(Student)'), value)
@pyqtSignature('receiver(Student)')
def receiver(self, value):
print value
def main():
#Andi = Student("Andi", "MB", 23523)
test = Test()
test.send(Student('Andi', 'MB',12345))
app = QtGui.QApplication(sys.argv)
Start = main()
sys.exit(app.exec_())
The failure message is:
Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\faankesk\Desktop\test\test.py", line 13, in <module>
class Test(QObject):
File "C:\Dokumente und Einstellungen\faankesk\Desktop\test\test.py", line 21, in Test
@pyqtSignature('receiver(Student)')
TypeError: C++ type 'Student' is not supported as a pyqtSlot signature argument type
#---------------------------------------------
Does anybody know why this doesn't work? I don't see the problem....
I hope you understood my problem....
Thank you for helping
Cascoin
Added after 27 minutes:
by the way I use Qt 4.7.1
I do have a problem with the signal/slot stuff.....
class Test(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.connect(self, SIGNAL('send(int)'), self, SLOT('receiver(int)'))
def send(self, value):
self.emit(SIGNAL('send(int)'), value)
@pyqtSignature('receiver(int)')
def receiver(self, value):
print value
def main():
test = Test()
test.send(12345)
app = QtGui.QApplication(sys.argv)
Start = main()
sys.exit(app.exec_())
Here you can see my very simple code... I have a class called Test.... I want that this class emits a signal and the same class receives this signal.
As the code is written above everything is fine....
Now I want to emit not a integer variable. I want to emit and receive a customer class... I simply changed int everywhere to my classes name and tried to run this code...
Here is how I did it....my customer class and the new code...
from PyQt4.QtCore import *
from PyQt4 import QtGui
import sys
class Student:
def __init__(self, name, Studium, Nr):
self.name = name
self.Fach = Studium
self.Matrikel = Nr
class Test(QObject):
def __init__(self, parent=None):
QObject.__init__(self, parent)
self.connect(self, SIGNAL('send(Student)'), self, SLOT('receiver(Student)'))
def send(self, value):
self.emit(SIGNAL('send(Student)'), value)
@pyqtSignature('receiver(Student)')
def receiver(self, value):
print value
def main():
#Andi = Student("Andi", "MB", 23523)
test = Test()
test.send(Student('Andi', 'MB',12345))
app = QtGui.QApplication(sys.argv)
Start = main()
sys.exit(app.exec_())
The failure message is:
Traceback (most recent call last):
File "C:\Dokumente und Einstellungen\faankesk\Desktop\test\test.py", line 13, in <module>
class Test(QObject):
File "C:\Dokumente und Einstellungen\faankesk\Desktop\test\test.py", line 21, in Test
@pyqtSignature('receiver(Student)')
TypeError: C++ type 'Student' is not supported as a pyqtSlot signature argument type
#---------------------------------------------
Does anybody know why this doesn't work? I don't see the problem....
I hope you understood my problem....
Thank you for helping
Cascoin
Added after 27 minutes:
by the way I use Qt 4.7.1