Group of toggleable push buttons with a tracked "last pressed" index.
More...
#include <gQtButtonsWidget.h>
|
| | GQTToggleButtonWidget (int buttonWidth, int buttonHeight, int borderRadius, const std::vector< std::string > &titles, bool vertical=true, QWidget *parent=nullptr) |
| | Constructs a GQTToggleButtonWidget.
|
| |
| int | buttonPressed () const |
| | Returns the last pressed button index.
|
| |
| bool | lastButtonState () const |
| | Returns the checked state of the last pressed button.
|
| |
| void | toggleButton (int index) |
| | Toggle the checked state of a button.
|
| |
| bool | buttonStatus (int index) const |
| | Returns the checked state for a specific button.
|
| |
| void | reset_buttons () |
| | Uncheck all buttons.
|
| |
| void | setSvgButtonIcon (int index, const QString &svgResourcePath, const QSize &iconSize=QSize()) |
| | Assign an SVG resource to a button so it re-renders on every palette/theme change.
|
| |
This widget constructs one checkable QPushButton per title and places them into a layout selected by vertical. When a button is clicked, the widget stores the pressed index and emits buttonPressedIndexChanged().
- Note
- This widget does not enforce mutual exclusivity; multiple buttons may be checked simultaneously. The "pressed index" refers to the last clicked button, not the only active button.
Definition at line 218 of file gQtButtonsWidget.h.
◆ GQTToggleButtonWidget()
| GQTToggleButtonWidget::GQTToggleButtonWidget |
( |
int | buttonWidth, |
|
|
int | buttonHeight, |
|
|
int | borderRadius, |
|
|
const std::vector< std::string > & | titles, |
|
|
bool | vertical = true, |
|
|
QWidget * | parent = nullptr ) |
|
explicit |
- Parameters
-
| buttonWidth | Fixed width of each button in pixels. |
| buttonHeight | Fixed height of each button in pixels. |
| borderRadius | Border radius (in pixels) used to round button corners. |
| titles | Titles (labels) for the buttons. |
| vertical | If true, buttons are arranged in a column; otherwise in a row. |
| parent | Parent widget (Qt ownership). Default is nullptr. |
Definition at line 170 of file gQtButtonsWidget.cc.
◆ buttonPressed()
| int GQTToggleButtonWidget::buttonPressed |
( |
| ) |
const |
|
inline |
If no button has been pressed yet, the value is -1.
- Returns
- Last pressed button index.
Definition at line 246 of file gQtButtonsWidget.h.
◆ buttonPressedIndexChanged
| void GQTToggleButtonWidget::buttonPressedIndexChanged |
( |
int | index | ) |
|
|
signal |
- Parameters
-
| index | The new pressed button index. |
◆ buttonStatus()
| bool GQTToggleButtonWidget::buttonStatus |
( |
int | index | ) |
const |
- Parameters
-
| index | Index of the button to query. Out-of-range values return false. |
- Returns
true if the button is checked; otherwise false.
Definition at line 224 of file gQtButtonsWidget.cc.
◆ changeEvent()
| void GQTToggleButtonWidget::changeEvent |
( |
QEvent * | event | ) |
|
|
overrideprotected |
◆ lastButtonState()
| bool GQTToggleButtonWidget::lastButtonState |
( |
| ) |
const |
If no button has been pressed yet, or if the stored index is out of range, returns false.
- Returns
true if the last pressed button is currently checked; otherwise false.
Definition at line 211 of file gQtButtonsWidget.cc.
◆ reset_buttons()
| void GQTToggleButtonWidget::reset_buttons |
( |
| ) |
|
◆ setSvgButtonIcon()
| void GQTToggleButtonWidget::setSvgButtonIcon |
( |
int | index, |
|
|
const QString & | svgResourcePath, |
|
|
const QSize & | iconSize = QSize() ) |
The SVG must use currentColor for all strokes and fills; the widget substitutes the active palette's WindowText color each time the palette or style changes, keeping icons readable in both light and dark mode.
- Parameters
-
| index | Index of the button to update. Out-of-range values are ignored. |
| svgResourcePath | Qt resource path, e.g. ":/images/hidden_lines.svg". |
| iconSize | Rendered size. Defaults to the button's fixed size minus 6 px padding. |
Definition at line 244 of file gQtButtonsWidget.cc.
◆ showEvent()
| void GQTToggleButtonWidget::showEvent |
( |
QShowEvent * | event | ) |
|
|
overrideprotected |
◆ toggleButton()
| void GQTToggleButtonWidget::toggleButton |
( |
int | index | ) |
|
- Parameters
-
| index | Index of the button to toggle. Out-of-range values are ignored. |
Definition at line 218 of file gQtButtonsWidget.cc.
The documentation for this class was generated from the following files: