|
gqtbuttonswidget
|
Icon-based button strip widget implemented using a QListWidget.
More...
#include <gQtButtonsWidget.h>
Public Member Functions | |
| GQTButtonsWidget (double h, double v, const std::vector< std::string > &bicons, bool vertical=true, QWidget *parent=nullptr) | |
Constructs a GQTButtonsWidget. | |
| ~GQTButtonsWidget () override=default | |
| int | button_pressed () const |
| Returns the index of the currently selected (pressed) button. | |
| void | press_button (int i) |
| Programmatically press a button. | |
| void | reset_buttons () |
| Reset all buttons to the "normal" icon state. | |
Data Fields | |
| 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:
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.Definition at line 93 of file gQtButtonsWidget.h.
|
explicit |
The constructor:
ButtonInfo per entry in bicons QListWidget in icon modeh and v vertical | 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 44 of file gQtButtonsWidget.cc.
|
overridedefault |
|
inline |
This returns the current row in the underlying QListWidget. If no item is selected, Qt typically reports -1.
buttonsWidget. Definition at line 142 of file gQtButtonsWidget.h.
| 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().
| i | Index of the button to press. Out-of-range values are ignored. |
Definition at line 100 of file gQtButtonsWidget.cc.
| void GQTButtonsWidget::reset_buttons | ( | ) |
This updates every stored QListWidgetItem icon to state 1. It does not change the current selection row.
Definition at line 118 of file gQtButtonsWidget.cc.
| QListWidget* GQTButtonsWidget::buttonsWidget |
Exposed for integration (e.g. embedding in larger GUIs, applying additional policies, connecting to more signals).
this and must not be deleted externally. Definition at line 131 of file gQtButtonsWidget.h.