- class QRadioButton#
The
QRadioButton
widget provides a radio button with a text label. More…Synopsis#
Methods#
def
__init__()
Virtual methods#
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
Warning
This section contains snippets that were automatically translated from C++ to Python and may contain errors.
A
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 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
QButtonGroup
.Whenever a button is switched on or off, it emits the
toggled()
signal. Connect to this signal if you want to trigger an action each time the button changes state. UseisChecked()
to see if a particular button is selected.Just like
QPushButton
, a radio button displays text, and optionally a small icon. The icon is set withsetIcon()
. The text can be set in the constructor or withsetText()
. 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)
In this example the shortcut is Alt+c. See the QShortcut documentation for details. To display an actual ampersand, use ‘&&’.
Important inherited members:
text()
,setText()
,text()
,setDown()
,isDown()
,autoRepeat()
,group()
,setAutoRepeat()
,toggle()
,pressed()
,released()
,clicked()
, andtoggled()
.See also
Constructs a radio button with the given
parent
, but with no text or pixmap.The
parent
argument is passed on to theQAbstractButton
constructor.- __init__(text[, parent=None])
- Parameters:
text – str
parent –
QWidget
Constructs a radio button with the given
parent
andtext
string.The
parent
argument is passed on to theQAbstractButton
constructor.- initStyleOption(button)#
- Parameters:
button –
QStyleOptionButton
Initialize
option
with the values from thisQRadioButton
. This method is useful for subclasses when they need aQStyleOptionButton
, but don’t want to fill in all the information themselves.See also