我正在为一个客户开发一个项目,其中设计有一个带有排他选项的单选按钮。Qt Python单选按钮:激活事件
以下是一段运行并显示两个漂亮的单选按钮的代码:
self.performGroupBox = QtGui.QGroupBox(self.centralwidget)
self.performGroupBox.setGeometry(QtCore.QRect(50, 20, 181, 121))
self.performGroupBox.setObjectName("performGroupBox")
self.consultRadioButton = QtGui.QRadioButton(self.performGroupBox)
self.consultRadioButton.setGeometry(QtCore.QRect(40, 30, 84, 18))
self.consultRadioButton.setObjectName("consultRadioButton")
self.insertRadioButton = QtGui.QRadioButton(self.performGroupBox)
self.insertRadioButton.setGeometry(QtCore.QRect(40, 60, 84, 18))
self.insertRadioButton.setObjectName("insertRadioButton")
它只是看起来像:
perform:
() Consult
() Insert
点这里,怎么知道什么是首选标记为:“consultRadioButton”或“insertRadioButton”?
这里是试图让这个信息的样本:
if self.consultRadioButton.isChecked():
self.call_Consult()
if self.insertRadioButton.isChecked():
self.call_Insert()
但选择了单选按钮时,它没有做任何事情。
否则,使用连接应该是另一种选择:
QtCore.QObject.connect(self.consultRadioButton, QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Consult)
QtCore.QObject.connect(self.insertRadioButton, QtCore.SIGNAL("currentIndexChanged(QString)"), self.call_Insert)
但它也不能工作。
这里缺少什么...有什么建议吗?
非常欢迎和赞赏所有评论。
链接现在已经死了。 – 2015-08-28 11:10:57