cf::ui::widget::material::Button¶
Material Design 3 Button widget. More...
#include <button.h>
Inherits from QPushButton
Public Types¶
| Name | |
|---|---|
| enum class | ButtonVariant { Filled, Tonal, Outlined, Text, Elevated} Button visual variant. |
Public Functions¶
| Name | |
|---|---|
| Q_ENUM(ButtonVariant ) | |
| Button(ButtonVariant variant =ButtonVariant::Filled, QWidget * parent =nullptr) Constructor with variant. |
|
| Button(constQString & text, ButtonVariant variant =ButtonVariant::Filled, QWidget * parent =nullptr) Constructor with text and variant. |
|
| ~Button() override Destructor. |
|
| int | elevation() const Gets the elevation level. |
| void | setElevation(int level) Sets the elevation level. |
| void | setLightSourceAngle(float degrees) Sets the light source angle for shadow. |
| float | lightSourceAngle() const Gets the light source angle. |
| void | setLeadingIcon(constQIcon & icon) Sets the leading icon. |
| void | setIcon(constQIcon & icon) Redirects setIcon to setLeadingIcon for convenience. |
| QIcon | icon() const Gets the current icon. |
| bool | pressEffectEnabled() const Gets whether press effect is enabled. |
| void | setPressEffectEnabled(bool enabled) Sets whether press effect is enabled. |
| ButtonVariant | variant() const Gets the button variant. |
| void | setVariant(ButtonVariant variant) Sets the button variant. |
| QSize | sizeHint() const override Gets the recommended size. |
| QSize | minimumSizeHint() const override Gets the minimum recommended size. |
Protected Functions¶
| Name | |
|---|---|
| void | paintEvent(QPaintEvent * event) override Paints the 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. |
Public Properties¶
| Name | |
|---|---|
| ButtonVariant | variant |
| int | elevation |
| bool | pressEffectEnabled |
Detailed Description¶
Material Design 3 Button widget.
Since: N/A
Implements Material Design 3 button with support for filled, tonal, outlined, text, and elevated variants. Includes ripple effects, state layers, elevation shadows, and focus indicators.
Public Types Documentation¶
enum ButtonVariant¶
| Enumerator | Value | Description |
|---|---|---|
| Filled | ||
| Tonal | ||
| Outlined | ||
| Text | ||
| Elevated |
Button visual variant.
Since: N/A
Public Functions Documentation¶
function Q_ENUM¶
function Button¶
Constructor with variant.
Parameters:
- variant Button visual variant.
- parent QObject parent.
Exceptions:
- None
Since: N/A
Note: None
Warning: None
function Button¶
explicit Button(
constQString & text,
ButtonVariant variant =ButtonVariant::Filled,
QWidget * parent =nullptr
)
Constructor with text and variant.
Parameters:
Exceptions:
- None
Since: N/A
Note: None
Warning: None
function ~Button¶
Destructor.
Exceptions:
- None
Since: N/A
Note: None
Warning: None
function elevation¶
Gets the elevation level.
Exceptions:
- None
Return: Elevation level (0-5).
Since: N/A
Note: Material Design defines 6 standard levels.
Warning: None
function setElevation¶
Sets the elevation level.
Parameters:
- level Elevation level (0-5).
Exceptions:
- None
Since: N/A
Note: Affects shadow rendering.
Warning: None
function setLightSourceAngle¶
Sets the light source angle for shadow.
Parameters:
- degrees Angle in degrees (-90 to 90).
Exceptions:
- None
Since: N/A
Note: Default is 15 degrees (light from top-left).
Warning: None
function lightSourceAngle¶
Gets the light source angle.
Exceptions:
- None
Return: Light source angle in degrees.
Since: N/A
Note: None
Warning: None
function setLeadingIcon¶
Sets the leading icon.
Parameters:
- icon Icon to display before text.
Exceptions:
- None
Since: N/A
Note: None
Warning: None
function setIcon¶
Redirects setIcon to setLeadingIcon for convenience.
Parameters:
- icon Icon to display before text.
Exceptions:
- None
Since: N/A
Note: None
Warning: None
function icon¶
Gets the current icon.
Exceptions:
- None
Return: Current icon.
Since: N/A
Note: None
Warning: None
function pressEffectEnabled¶
Gets whether press effect is enabled.
Exceptions:
- None
Return: true if press effect is enabled, false otherwise.
Since: N/A
Note: None
Warning: None
function setPressEffectEnabled¶
Sets whether press effect is enabled.
Parameters:
- enabled true to enable press effect, false to disable.
Exceptions:
- None
Since: N/A
Note: Press effect includes elevation change and ripple.
Warning: None
function variant¶
Gets the button variant.
Exceptions:
- None
Return: Current button variant.
Since: N/A
Note: None
Warning: None
function setVariant¶
Sets the button variant.
Parameters:
- variant Button variant to use.
Exceptions:
- None
Since: N/A
Note: Changing variant updates the visual appearance.
Warning: None
function sizeHint¶
Gets the recommended size.
Exceptions:
- None
Return: Recommended size for the button.
Since: N/A
Note: Based on text, icon, and padding.
Warning: None
function minimumSizeHint¶
Gets the minimum recommended size.
Exceptions:
- None
Return: Minimum recommended size.
Since: N/A
Note: Ensures touch target size requirements.
Warning: None
Protected Functions Documentation¶
function paintEvent¶
Paints the button.
Parameters:
- event Paint event.
Exceptions:
- None
Since: N/A
Note: Implements 7-step Material Design paint pipeline.
Warning: None
function enterEvent¶
Handles mouse enter event.
Parameters:
- event Enter event.
Exceptions:
- None
Since: N/A
Note: Updates hover state.
Warning: None
function leaveEvent¶
Handles mouse leave event.
Parameters:
- event Leave event.
Exceptions:
- None
Since: N/A
Note: Updates hover state.
Warning: None
function mousePressEvent¶
Handles mouse press event.
Parameters:
- event Mouse event.
Exceptions:
- None
Since: N/A
Note: Triggers ripple and press state.
Warning: None
function mouseReleaseEvent¶
Handles mouse release event.
Parameters:
- event Mouse event.
Exceptions:
- None
Since: N/A
Note: Updates press state.
Warning: None
function focusInEvent¶
Handles focus in event.
Parameters:
- event Focus event.
Exceptions:
- None
Since: N/A
Note: Shows focus indicator.
Warning: None
function focusOutEvent¶
Handles focus out event.
Parameters:
- event Focus event.
Exceptions:
- None
Since: N/A
Note: Hides focus indicator.
Warning: None
function changeEvent¶
Handles widget state change event.
Parameters:
- event Change event.
Exceptions:
- None
Since: N/A
Note: Updates appearance based on state changes.
Warning: None
Public Property Documentation¶
property variant¶
property elevation¶
property pressEffectEnabled¶
Updated on 2026-03-09 at 10:14:00 +0000