How to check if a checkbox is checked in pyqt

pyqt4, python-2.7

Solution

`self.folderactive.isChecked` isn't a boolean, it's a method - which, in a boolean context, will always evaluate to `True`. If you want the state of the checkbox, just invoke the method:

if self.folderactive.isChecked():
    ...
else:
    ...

Problem

I'm trying to make a conditional statement based on whether a checkbox is checked or not. I've tried something like the following, but it always returns as true. ``` self.folderactive = QtGui.QCheckBox(self.folders) self.folderactive.setGeometry(QtCore.QRect(50, 390, 71, 21)) self.folderactive.setObjectName(_fromUtf8("folderactive")) if self.folderactive.isChecked: folders.createDir('Desktop') print "pass" elif not self.folderactive.isChecked: folders.deleteDir('Desktop') print "nopass" ``` Is there a way to get a bool value of whether a checkbox is checked or not?

Original source