跳转至

cf::ui::widget::material::RadioButton

Material Design 3 RadioButton widget. More...

#include <radiobutton.h>

Inherits from QRadioButton

Public Functions

Name
RadioButton(QWidget * parent =nullptr)
Constructor.
RadioButton(constQString & text, QWidget * parent =nullptr)
Constructor with text.
~RadioButton() override
Destructor.
bool hasError() const
Gets whether the radio button is in error state.
void setError(bool error)
Sets the error state.
bool pressEffectEnabled() const
Gets whether press effect is enabled.
void setPressEffectEnabled(bool enabled)
Sets whether press effect is enabled.
void setChecked(bool checked)
Sets the checked state of the radio button.
QSize sizeHint() const override
Gets the recommended size.
QSize minimumSizeHint() const override
Gets the minimum recommended size.
bool hitButton(constQPoint & pos) const override
Handles hit test for mouse events.

Protected Functions

Name
void paintEvent(QPaintEvent * event) override
Paints the radio button.
void enterEvent(QEnterEvent * event) override
Handles mouse enter event.
void leaveEvent(QEvent * event) override
Handles mouse leave event.
void mousePressEvent(QMouseEvent * event) override
Handles mouse press event.
void mouseReleaseEvent(QMouseEvent * event) override
Handles mouse release event.
void focusInEvent(QFocusEvent * event) override
Handles focus in event.
void focusOutEvent(QFocusEvent * event) override
Handles focus out event.
void changeEvent(QEvent * event) override
Handles widget state change event.
void nextCheckState() override
Handles check state change event.

Public Properties

Name
bool error
bool pressEffectEnabled

Detailed Description

class cf::ui::widget::material::RadioButton;

Material Design 3 RadioButton widget.

Since: 0.1

Implements Material Design 3 radio button with circular selection area, inner circle scale animation, ripple effects, and focus indicators. Supports mutual exclusion through QButtonGroup integration.

Public Functions Documentation

function RadioButton

explicit RadioButton(
    QWidget * parent =nullptr
)

Constructor.

Parameters:

  • parent QObject parent.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function RadioButton

explicit RadioButton(
    constQString & text,
    QWidget * parent =nullptr
)

Constructor with text.

Parameters:

  • text Button text label.
  • parent QObject parent.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function ~RadioButton

~RadioButton() override

Destructor.

Exceptions:

  • None

Since: 0.1

Note: None

Warning: None

function hasError

bool hasError() const

Gets whether the radio button is in error state.

Exceptions:

  • None

Return: true if in error state, false otherwise.

Since: 0.1

Note: Error state displays with error color theme.

Warning: None

function setError

void setError(
    bool error
)

Sets the error state.

Parameters:

  • error true to set error state, false otherwise.

Exceptions:

  • None

Since: 0.1

Note: Error state displays with error color theme.

Warning: None

function pressEffectEnabled

bool pressEffectEnabled() const

Gets whether press effect is enabled.

Exceptions:

  • None

Return: true if press effect is enabled, false otherwise.

Since: 0.1

Note: None

Warning: None

function setPressEffectEnabled

void setPressEffectEnabled(
    bool enabled
)

Sets whether press effect is enabled.

Parameters:

  • enabled true to enable press effect, false to disable.

Exceptions:

  • None

Since: 0.1

Note: Press effect includes ripple animation.

Warning: None

function setChecked

void setChecked(
    bool checked
)

Sets the checked state of the radio button.

Parameters:

  • checked true to check, false to uncheck.

Exceptions:

  • None

Since: 0.1

Note: Override to sync inner circle scale with checked state.

Warning: None

function sizeHint

QSize sizeHint() const override

Gets the recommended size.

Exceptions:

  • None

Return: Recommended size for the radio button.

Since: 0.1

Note: Based on text and touch target requirements.

Warning: None

function minimumSizeHint

QSize minimumSizeHint() const override

Gets the minimum recommended size.

Exceptions:

  • None

Return: Minimum recommended size.

Since: 0.1

Note: Ensures touch target size requirements (48dp).

Warning: None

function hitButton

bool hitButton(
    constQPoint & pos
) const override

Handles hit test for mouse events.

Parameters:

  • pos Mouse position.

Exceptions:

  • None

Return: true if the position is within the clickable area.

Since: 0.1

Note: Entire widget area is clickable.

Warning: None

Protected Functions Documentation

function paintEvent

void paintEvent(
    QPaintEvent * event
) override

Paints the radio button.

Parameters:

  • event Paint event.

Exceptions:

  • None

Since: 0.1

Note: Implements Material Design paint pipeline.

Warning: None

function enterEvent

void enterEvent(
    QEnterEvent * event
) override

Handles mouse enter event.

Parameters:

  • event Enter event.

Exceptions:

  • None

Since: 0.1

Note: Updates hover state.

Warning: None

function leaveEvent

void leaveEvent(
    QEvent * event
) override

Handles mouse leave event.

Parameters:

  • event Leave event.

Exceptions:

  • None

Since: 0.1

Note: Updates hover state.

Warning: None

function mousePressEvent

void mousePressEvent(
    QMouseEvent * event
) override

Handles mouse press event.

Parameters:

  • event Mouse event.

Exceptions:

  • None

Since: 0.1

Note: Triggers ripple and press state.

Warning: None

function mouseReleaseEvent

void mouseReleaseEvent(
    QMouseEvent * event
) override

Handles mouse release event.

Parameters:

  • event Mouse event.

Exceptions:

  • None

Since: 0.1

Note: Updates press state.

Warning: None

function focusInEvent

void focusInEvent(
    QFocusEvent * event
) override

Handles focus in event.

Parameters:

  • event Focus event.

Exceptions:

  • None

Since: 0.1

Note: Shows focus indicator.

Warning: None

function focusOutEvent

void focusOutEvent(
    QFocusEvent * event
) override

Handles focus out event.

Parameters:

  • event Focus event.

Exceptions:

  • None

Since: 0.1

Note: Hides focus indicator.

Warning: None

function changeEvent

void changeEvent(
    QEvent * event
) override

Handles widget state change event.

Parameters:

  • event Change event.

Exceptions:

  • None

Since: 0.1

Note: Updates appearance based on state changes.

Warning: None

function nextCheckState

void nextCheckState() override

Handles check state change event.

Parameters:

  • checked Check state.

Exceptions:

  • None

Since: 0.1

Note: Triggers inner circle scale animation.

Warning: None

Public Property Documentation

property error

bool error;

property pressEffectEnabled

bool pressEffectEnabled;

Updated on 2026-03-09 at 10:14:00 +0000