python - 如何取消选中pyqt4中选中的单选按钮

标签 python pyqt pyqt4 qradiobutton

我正在做一个测验,在按下下一个按钮后,我希望取消选中单选按钮,但这并没有发生。这是我放置单选按钮的地方。

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)

这里是连接到我的下一个按钮的子例程。在这里,我尝试将单选按钮设置为清晰,但并没有发生。单选按钮仍然具有上一个问题中的先前选择。

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)

谁能告诉我哪里出错了?谢谢

最佳答案

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)

尝试此代码以进一步引用此 link

关于python - 如何取消选中pyqt4中选中的单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29380143/

相关文章:

python - PyCharm 和 ipython 的组合无法导入 qt5 或 Qt5Agg

Python 将多个数据框中的列合并到单个数据框中

python - 如何从多选 QComboBox 中获取选中的项目?

c# - 在多线程 C# 应用程序中嵌入 Python

python - PyQt:获取 QGraphicsWidgets 在 QGraphicsGridLayout 中的位置

python - 是否可以在 Virtualenv 沙箱上添加 PyQt4/PySide 包?

使用 Qt4 进行 Python 分散更新 - Qslider

python - pyqt4如何实现多语言支持

python - 合法的 python if 语句?

python - 如何访问这个没有 id 的 <div class> 内的文本?使用BeautifulSoup