I have built a group checkbox by:
self.group = QtGui.QButtonGroup()
How can I get the checkbox text which is/are clicked ?
self.group.buttonClicked.connect(self.btnCliked)
The buttonClicked
signal sends the button that was clicked, so all you need is:
def btnClicked(self, button):
print(button.text())
Are you using the button/radios/checks exclusively (meaning just one can be selected at a time)? Depending on what you want to do you can either use the argument of the "clicked"-signal like:
self.group.clicked.connect(self.btnClicked)
def btnClicked(self, button):
self.text = button.text()
or you can also use each on_button_clicked function, which is pretty much the same (you dont need to connect the signal, its done automatically):
...
@QtCore.pyqtSignature('')
def on_mybutton1_clicked(self, button):
self.text = button.text()
@QtCore.pyqtSignature('')
def on_mybutton2_clicked(self, button):
self.text = button.text()
...
("mybutton1" in "on_mybutton1_clicked" is the name of each button)
or if you want to get the state at a action later on, like at a button press of another button, you can do it like:
def on_anyaction(self):
button = self.group.selected()
self.text = button.text()
I hope this helps an gives you some input...