QRadioButton

Inheritance diagram of PySide2.QtWidgets.QRadioButton

Synopsis

Functions

Detailed Description

The PySide2.QtWidgets.QRadioButton widget provides a radio button with a text label.

../../_images/windows-radiobutton.png

A PySide2.QtWidgets.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 PySide2.QtWidgets.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 PySide2.QtWidgets.QButtonGroup .

Whenever a button is switched on or off, it emits the PySide2.QtWidgets.QAbstractButton.toggled() signal. Connect to this signal if you want to trigger an action each time the button changes state. Use PySide2.QtWidgets.QAbstractButton.isChecked() to see if a particular button is selected.

Just like PySide2.QtWidgets.QPushButton , a radio button displays text, and optionally a small icon. The icon is set with PySide2.QtWidgets.QAbstractButton.setIcon() . The text can be set in the constructor or with PySide2.QtWidgets.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)

In this example the shortcut is Alt+c . See the QShortcut documentation for details. To display an actual ampersand, use ‘&&’.

Important inherited members: PySide2.QtWidgets.QAbstractButton.text() , PySide2.QtWidgets.QAbstractButton.setText() , PySide2.QtWidgets.QAbstractButton.text() , PySide2.QtWidgets.QAbstractButton.setDown() , PySide2.QtWidgets.QAbstractButton.isDown() , PySide2.QtWidgets.QAbstractButton.autoRepeat() , PySide2.QtWidgets.QAbstractButton.group() , PySide2.QtWidgets.QAbstractButton.setAutoRepeat() , PySide2.QtWidgets.QAbstractButton.toggle() , PySide2.QtWidgets.QAbstractButton.pressed() , PySide2.QtWidgets.QAbstractButton.released() , PySide2.QtWidgets.QAbstractButton.clicked() , and PySide2.QtWidgets.QAbstractButton.toggled() .

class PySide2.QtWidgets.QRadioButton([parent=nullptr])
class PySide2.QtWidgets.QRadioButton(text[, parent=nullptr])
Parameters:

Constructs a radio button with the given parent , but with no text or pixmap.

The parent argument is passed on to the PySide2.QtWidgets.QAbstractButton constructor.

Constructs a radio button with the given parent and text string.

The parent argument is passed on to the PySide2.QtWidgets.QAbstractButton constructor.

PySide2.QtWidgets.QRadioButton.initStyleOption(button)
Parameters:buttonPySide2.QtWidgets.QStyleOptionButton

Initialize option with the values from this PySide2.QtWidgets.QRadioButton . This method is useful for subclasses when they need a PySide2.QtWidgets.QStyleOptionButton , but don’t want to fill in all the information themselves.