我正在使用以下示例
class bar(QObject):
def mySlot(self,p):
print "This is my slot " + str(p)
class Foo(QObject):
trigger = pyqtSignal()
def my_connect_and_emit_trigger(self):
self.trigger.emit(12)
def handle_trigger(self):
# Show that the slot has been called.
print "trigger signal received"
b = bar()
a = Foo()
a.trigger.connect(int,b.mySlot) <---how to fix this
a.connect_and_emit_trigger()
我正在尝试将带有一个int参数的插槽b.mySlot
附加到信号a.trigger
我的问题是我做错了什么。我找不到任何有助于信号参数的材料。
答案 0 :(得分:1)
这是正确的:
class bar(QObject):
def mySlot(self,p):
print "This is my slot " + str(p)
class Foo(QObject):
trigger = pyqtSignal(int)
def my_connect_and_emit_trigger(self):
self.trigger.emit(12)
def handle_trigger(self):
# Show that the slot has been called.
print "trigger signal received"
b = bar()
a = Foo()
a.trigger.connect(b.mySlot)
a.my_connect_and_emit_trigger()
Doc是here