Icon-based button strip widget implemented using a QListWidget.
More...
#include <gQtButtonsWidget.h>
|
| QListWidget * | buttonsWidget |
| | Underlying QListWidget used to render the icons.
|
| |
GQTButtonsWidget uses a QListWidget in QListView::IconMode as the rendering backend. Each entry is a QListWidgetItem whose icon is updated to reflect interaction.
Typical behavior:
- When a user presses an item, all items are reset to the "normal" icon (state
1) and the pressed item is set to the "pressed" icon (state 2).
press_button() allows pressing a button programmatically.
reset_buttons() restores all icons to the "normal" state.
- Note
- This widget is intended for use in the Qt GUI thread.
Definition at line 97 of file gQtButtonsWidget.h.
◆ GQTButtonsWidget()
| GQTButtonsWidget::GQTButtonsWidget |
( |
double | h, |
|
|
double | v, |
|
|
const std::vector< std::string > & | bicons, |
|
|
bool | vertical = true, |
|
|
QWidget * | parent = nullptr ) |
|
explicit |
The constructor:
- creates one internal
ButtonInfo per entry in bicons
- instantiates and configures a
QListWidget in icon mode
- sets icon size based on
h and v
- lays out the list vertically or horizontally based on
vertical
- Parameters
-
| h | Icon width in pixels (used for QListWidget::setIconSize()). |
| v | Icon height in pixels (used for QListWidget::setIconSize()). |
| bicons | Vector of base icon names used to locate icons. |
| vertical | If true, buttons are arranged in a column; otherwise in a row. |
| parent | Parent widget (Qt ownership). Default is nullptr. |
Definition at line 58 of file gQtButtonsWidget.cc.
◆ ~GQTButtonsWidget()
| GQTButtonsWidget::~GQTButtonsWidget |
( |
| ) |
|
|
overridedefault |
◆ button_pressed()
| int GQTButtonsWidget::button_pressed |
( |
| ) |
const |
|
inline |
This returns the current row in the underlying QListWidget. If no item is selected, Qt typically reports -1.
- Returns
- Index of the current row in
buttonsWidget.
Definition at line 146 of file gQtButtonsWidget.h.
◆ changeEvent()
| void GQTButtonsWidget::changeEvent |
( |
QEvent * | event | ) |
|
|
overrideprotected |
◆ press_button()
| void GQTButtonsWidget::press_button |
( |
int | i | ) |
|
This sets the current row and updates the pressed button's icon to the "pressed" state (state 2). It does not automatically reset other icons; if you need a clean state first, call reset_buttons().
- Parameters
-
| i | Index of the button to press. Out-of-range values are ignored. |
Definition at line 117 of file gQtButtonsWidget.cc.
◆ reset_buttons()
| void GQTButtonsWidget::reset_buttons |
( |
| ) |
|
This updates every stored QListWidgetItem icon to state 1. It does not change the current selection row.
Definition at line 128 of file gQtButtonsWidget.cc.
◆ showEvent()
| void GQTButtonsWidget::showEvent |
( |
QShowEvent * | event | ) |
|
|
overrideprotected |
◆ buttonsWidget
| QListWidget* GQTButtonsWidget::buttonsWidget |
Exposed for integration (e.g. embedding in larger GUIs, applying additional policies, connecting to more signals).
- Warning
- The widget is parented to
this and must not be deleted externally.
Definition at line 135 of file gQtButtonsWidget.h.
The documentation for this class was generated from the following files: