Skip to main content

QCustomRadioGroup

QCustomRadioGroup

A labelled set of single-choice options.

Owns a set of QCustomRadioButton children and the mutual exclusion between them, so the group - not the buttons - is the single source of truth for "what is selected". That matters in Qt Designer, where you cannot wire up sibling relationships by hand.

Options are authored in code with setOptions([...]) or in Qt Designer with the optionsCsv property, following the valuesCsv convention used by the chart widgets:

optionsCsv = "Free,Pro,Studio" labels double as values optionsCsv = "free=Free,pro=Pro,studio=Studio" explicit value=label

Emits valueChanged(str) and currentIndexChanged(int).

At a glance

TierFree (GPLv3)
Importfrom Custom_Widgets.QCustomRadioGroup import QCustomRadioGroup
Qt DesignerYes — drag it from the palette

Quick start

from Custom_Widgets.QCustomRadioGroup import QCustomRadioGroup

widget = QCustomRadioGroup()

Dark theme

Colours come from the design tokens, so the widget follows the app theme with no extra work.

QCustomRadioGroup in dark theme

Properties

Every property below is settable in code and in Qt Designer.

PropertyTypeDefault
optionsCsvstringOption one,Option two,Option three
selectedValuestring
titlestring
orientationenum: vertical/horizontal``vertical
spacingPxint10
sizeVariantenum: sm/md/lg``md
titleColorcolor

Signals

Signal
currentIndexChanged(int)
valueChanged(QString)

Methods

MethodDescription
buttons()Buttons.
clearSelection()Clear the selection.
count()Count.
currentIndex()Current index.
currentIndexChanged(...)Current index changed.
currentLabel()Current label.
options()Options.
optionsCsv(*args, **kwargs)Options csv.
orientation(*args, **kwargs)Orientation.
selectedValue(*args, **kwargs)Selected value.
setCurrentIndex(index)Set the current index.
setOptions(options)Replace every option. Selection is kept if its value survives.
setValue(value)Set the value.
sizeVariant(*args, **kwargs)Size variant.
spacingPx(*args, **kwargs)Spacing px.
title(*args, **kwargs)Title.
titleColor(*args, **kwargs)Title color.
value()Value.
valueChanged(...)Value changed.

Theming

Colours come from the design tokens, so they follow the active theme. Roles used: accent, outline, on-surface.

See Design tokens.

Runnable example

A complete app using this widget lives at examples/PySide6/QCustomRadioGroup/main.py.

QCustomButtonGroup · QCustomCheckBox · QCustomColorPicker · QCustomComboBox · QCustomDateEdit · QCustomDateRangePicker · QCustomEmojiPicker · QCustomFileDropZone