Module Qt Designer Check Box

Qt documentation will likely be the most helpful source when figuring out what signals are available for a QWidget object. You can see QCheckBox signals at QCheckBox Class | Qt Widgets 5.15.3. QCheckBox also inherits from QAbstractButton which is why the clicked() signal is available as well QAbstractButton Class | Qt Widgets 5.15.3.

Based on what is available there isn’t a signal specifically for when it is checked versus unchecked, so you will have to handle it within your slot onButtonGrabber.

In the example below I use the signal stateChanged from the QCheckBox class which is a little more detailed in that it provides the Qt CheckState (checked, unchecked, partially checked) rather than just a simple boolean as provided by the clicked signal.

def setup(self):
  self.ui.EnableFolderGrab.stateChanged.connect(self.onButtonGrabber)

def onButtonGrabber(self, checkState):
  if checkState == qt.Qt.Checked:
    print("This checkbox was checked")
  elif checkState == qt.Qt.Unchecked:
    print("This checkbox was unchecked")
1 Like