PDA

View Full Version : Which QCheckBox has been checked?



alexandernst
13th September 2009, 17:14
I have 3 QCheckBox'es and I would like to know which one has been checked.
I use this to connect them:


QObject.connect(self.ui.checkbox1, SIGNAL("toggled(bool)"), self.__on_check)
QObject.connect(self.ui.checkbox2, SIGNAL("toggled(bool)"), self.__on_check)
QObject.connect(self.ui.checkbox3, SIGNAL("toggled(bool)"), self.__on_check)
(this is python)

Thanks

ChrisW67
14th September 2009, 02:15
You could use QObject::sender() in the slot code to pick the triggering object.

Alternatively, you could use a QSignalMapper or put your check boxes into a QButtonGroup. Both these options allow your slot to receive a parameter identifying the clicked button.

alexandernst
14th September 2009, 10:09
Yeah! That worked great :) (self.sender())
Thanks