horizontal_button_group.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * Software License Agreement
4  *
5  * Copyright (c) 2020,
6  * TU Dortmund - Institute of Control Theory and Systems Engineering.
7  * All rights reserved.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  *
22  * Authors: Christoph Rösmann
23  *********************************************************************/
24 
25 #ifndef SRC_GUI_INCLUDE_CORBO_GUI_HORIZONTAL_BUTTON_GROUP_H_
26 #define SRC_GUI_INCLUDE_CORBO_GUI_HORIZONTAL_BUTTON_GROUP_H_
27 
28 #include <QAbstractButton>
29 #include <QHBoxLayout>
30 #include <QLabel>
31 
32 namespace corbo {
33 namespace gui {
34 
35 class HoriontalButtonGroup : public QWidget
36 {
37  Q_OBJECT
38  public:
39  explicit HoriontalButtonGroup(bool exclusive, QWidget* parent = 0) : HoriontalButtonGroup("", exclusive, parent) {}
40  explicit HoriontalButtonGroup(const QString& label, bool exclusive = false, QWidget* parent = 0);
42 
43  QAbstractButton* addButton(bool checked, const QString& cb_label = "");
44 
45  void setLabel(const QString& label) { _label->setText(label); }
46  virtual QSize sizeHint() const;
47  QLabel* widgetLabel() { return _label; }
48  const QLabel* widgetLabel() const { return _label; }
49  QAbstractButton* widgetButton(int idx);
50  QVector<bool> buttonStates() const;
51  void setButtonStates(const QVector<bool>& states);
52  int noButtons() const { return _boxes.size(); }
53  bool isExclusive() const { return _exclusive; }
54 
55  private:
56  QList<QAbstractButton*> _boxes;
57  QLabel* _label;
58  QHBoxLayout* _layout;
59  bool _exclusive = false;
60 };
61 
62 } // namespace gui
63 } // namespace corbo
64 
65 #endif // SRC_GUI_INCLUDE_CORBO_GUI_HORIZONTAL_BUTTON_GROUP_H_
corbo::gui::HoriontalButtonGroup::widgetButton
QAbstractButton * widgetButton(int idx)
Definition: horizontal_button_group.cpp:106
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::gui::HoriontalButtonGroup::isExclusive
bool isExclusive() const
Definition: horizontal_button_group.h:119
corbo::gui::HoriontalButtonGroup::setButtonStates
void setButtonStates(const QVector< bool > &states)
Definition: horizontal_button_group.cpp:120
corbo::gui::HoriontalButtonGroup::noButtons
int noButtons() const
Definition: horizontal_button_group.h:118
corbo::gui::HoriontalButtonGroup::~HoriontalButtonGroup
~HoriontalButtonGroup()
Definition: horizontal_button_group.h:107
corbo::gui::HoriontalButtonGroup::_exclusive
bool _exclusive
Definition: horizontal_button_group.h:125
corbo::gui::HoriontalButtonGroup::sizeHint
virtual QSize sizeHint() const
Definition: horizontal_button_group.cpp:135
corbo::gui::HoriontalButtonGroup::buttonStates
QVector< bool > buttonStates() const
Definition: horizontal_button_group.cpp:111
corbo::gui::HoriontalButtonGroup::_layout
QHBoxLayout * _layout
Definition: horizontal_button_group.h:124
corbo::gui::HoriontalButtonGroup::_boxes
QList< QAbstractButton * > _boxes
Definition: horizontal_button_group.h:122
corbo::gui::HoriontalButtonGroup::setLabel
void setLabel(const QString &label)
Definition: horizontal_button_group.h:111
corbo::gui::HoriontalButtonGroup::HoriontalButtonGroup
HoriontalButtonGroup(bool exclusive, QWidget *parent=0)
Definition: horizontal_button_group.h:105
corbo::gui::HoriontalButtonGroup::addButton
QAbstractButton * addButton(bool checked, const QString &cb_label="")
Definition: horizontal_button_group.cpp:89
corbo::gui::HoriontalButtonGroup::widgetLabel
QLabel * widgetLabel()
Definition: horizontal_button_group.h:113
corbo::gui::HoriontalButtonGroup::_label
QLabel * _label
Definition: horizontal_button_group.h:123


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:47