kann mir jemand mit PyQt4 helfen?
Ich möchte ein Signal von einer Klasse zu einer anderen schicken.
Weiß jemand, warum es mit connectSLotsByName nicht funktioniert?
Code: Alles auswählen
import sys
from PyQt4.QtCore import *
class helper(QObject):
def __init__(self, parent):
QObject.__init__(self)
parent.setObjectName("helper")
QMetaObject.connectSlotsByName(parent)
def send(self):
print "sending"
self.emit(SIGNAL("test"))
class main(helper, QObject):
def __init__(self, parent=None):
QObject.__init__(self)
self.send()
@pyqtSignature("")
def on_helper_test(self):
print "working"
if __name__ == "__main__":
app = QApplication(sys.argv)
main = main()
app.exec_()
Code: Alles auswählen
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class helper(QObject):
def __init__(self, parent):
QObject.__init__(self)
parent.setObjectName("helper")
#QMetaObject.connectSlotsByName(parent)
def send(self):
print "sending"
self.emit(SIGNAL("test()"))
class main(helper, QObject):
def __init__(self, parent=None):
QObject.__init__(self)
self.connect(self, SIGNAL("test()"), self.test_connect)
self.send()
#@pyqtSignature("")
#def on_helper_test(self):
# print "working"
def test_connect(self):
print "working, connect"
if __name__ == "__main__":
app = QApplication(sys.argv)
main = main()
app.exec_()