PySide.QtGui.QRadioButton widget provides a radio button with a text label.
A PySide.QtGui.QRadioButton is an option button that can be switched on (checked) or off (unchecked). Radio buttons typically present the user with a “one of many” choice. In a group of radio buttons only one radio button at a time can be checked; if the user selects another button, the previously selected button is switched off.
Radio buttons are PySide.QtGui.QAbstractButton.autoExclusive() by default. If auto-exclusive is enabled, radio buttons that belong to the same parent widget behave as if they were part of the same exclusive button group. If you need multiple exclusive button groups for radio buttons that belong to the same parent widget, put them into a PySide.QtGui.QButtonGroup .
Whenever a button is switched on or off it emits the PySide.QtGui.QAbstractButton.toggled() signal. Connect to this signal if you want to trigger an action each time the button changes state. Use PySide.QtGui.QAbstractButton.isChecked() to see if a particular button is selected.
就像 PySide.QtGui.QPushButton , a radio button displays text, and optionally a small icon. The icon is set with PySide.QtGui.QAbstractButton.setIcon() . The text can be set in the constructor or with PySide.QtGui.QAbstractButton.setText() . A shortcut key can be specified by preceding the preferred character with an ampersand in the text. For example:
button = QRadioButton("Search from the &cursor", self)
在此范例中快捷方式是 Alt+c 。见 QShortcut documentation for details (to display an actual ampersand, use ‘&&').
Important inherited members: PySide.QtGui.QAbstractButton.text() , PySide.QtGui.QAbstractButton.setText() , PySide.QtGui.QAbstractButton.text() , PySide.QtGui.QAbstractButton.setDown() , PySide.QtGui.QAbstractButton.isDown() , PySide.QtGui.QAbstractButton.autoRepeat() , PySide.QtGui.QAbstractButton.group() , PySide.QtGui.QAbstractButton.setAutoRepeat() , PySide.QtGui.QAbstractButton.toggle() , PySide.QtGui.QAbstractButton.pressed() , PySide.QtGui.QAbstractButton.released() , PySide.QtGui.QAbstractButton.clicked() ,和 PySide.QtGui.QAbstractButton.toggled() .
|
A radio button shown in the Plastique widget style . |
|
A radio button shown in the Windows XP widget style . |
|
A radio button shown in the Macintosh widget style . |
另请参阅
PySide.QtGui.QPushButton PySide.QtGui.QToolButton PySide.QtGui.QCheckBox GUI Design Handbook: Radio Button 组框范例
| 参数: |
|
|---|
Constructs a radio button with the given parent , but with no text or pixmap.
parent argument is passed on to the PySide.QtGui.QAbstractButton 构造函数。
Constructs a radio button with the given parent 和 text string.
parent argument is passed on to the PySide.QtGui.QAbstractButton 构造函数。
| 参数: | button – PySide.QtGui.QStyleOptionButton |
|---|
初始化 option 采用值来自此 PySide.QtGui.QRadioButton 。此方法对子类是有用的,当需要 PySide.QtGui.QStyleOptionButton ,但不希望自己填充所有信息。