使用布尔参数发送信号

时间:2014-05-21 15:09:06

标签: python python-2.7 pyside signals-slots

文件1:

class A(QObject):
    status = Signal()
.
.
def func1(self, boolean_var):
    self.emit.status()

文件2:

class B(QMainWindow):
.
.
self.model.status.connect(self.update)
@Slot()
def update(self):
    # here i have to process data based on the boolean argument passed through signal

我在这里使用了signal()而没有参数,但是我怎么能在这里添加一个参数呢?

1 个答案:

答案 0 :(得分:2)

如果read the documentation

,这很容易
from PySide import QtCore


class A(QtCore.QObject):
    status = QtCore.Signal(bool)

    def func1(self, *args):
        self.status.emit(*args)

# later...


@QtCore.Slot(bool)
def update(self, bool_args):
    pass  # insert what you need to do here.