Search code examples
pythonpython-2.7pysidesignals-slots

Send signal with boolean argument


File 1:

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

File 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

I have used signal() without arguments here, but how can i add an argument to it here ?


Solution

  • This is easy if you 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.