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.
|
| |
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 200 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 133 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 228 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 191 of file gQtButtonsWidget.cc.
◆ 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 178 of file gQtButtonsWidget.cc.
◆ reset_buttons()
| void GQTToggleButtonWidget::reset_buttons |
( |
| ) |
|
◆ toggleButton()
| void GQTToggleButtonWidget::toggleButton |
( |
int | index | ) |
|
- Parameters
-
| index | Index of the button to toggle. Out-of-range values are ignored. |
Definition at line 185 of file gQtButtonsWidget.cc.
The documentation for this class was generated from the following files: