How to uncheck a checked radio buttons in pyqt4
13,799
def Showquestions2(self):
self.group.setExclusive(False)
self.Questionum.setText("Question 2")
self.Correctanswer.setChecked(False)
self.Incorrectans1.setChecked(False)
self.Incorrectans2.setChecked(False)
self.Incorrectans3.setChecked(False)
self.ismultichoiceButton.clicked.connect(self.Showquestions3)
self.group.setExclusive(True)
Try this code for further refer this link
Author by
Spike7
Updated on June 06, 2022Comments
-
Spike7 almost 2 years
Im making a quiz and after my next button is pressed i want the the radio buttons to be unchecked but this isnt happening. Here is where i put the radio buttons.
self.answers = QtGui.QButtonGroup(self) self.Correctanswer = QRadioButton() self.Incorrectans1 = QRadioButton() self.Incorrectans2 = QRadioButton() self.Incorrectans3 = QRadioButton() self.answers.addButton(self.Correctanswer) self.answers.addButton(self.Incorrectans1) self.answers.addButton(self.Incorrectans2) self.answers.addButton(self.Incorrectans3) self.answers.buttonClicked.connect(self.QuestionCheck) self.Correctanswer.setAutoExclusive(True) self.Incorrectans1.setAutoExclusive(True) self.Incorrectans2.setAutoExclusive(True) self.Incorrectans3.setAutoExclusive(True)
Here the subroutine which is connected to my next button. And here i try to set the radio buttons to be clear but that isnt happening. The radio button still has its previous choice from the last question.
def Showquestions2(self): self.Questionum.setText("Question 2") self.Correctanswer.setChecked(False) self.Incorrectans1.setChecked(False) self.Incorrectans2.setChecked(False) self.Incorrectans3.setChecked(False) self.ismultichoiceButton.clicked.connect(self.Showquestions3)
Could anyone tell me where im going wrong? thanks