label_slider_widget.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_LABEL_SLIDER_WIDGET_H_
26 #define SRC_GUI_INCLUDE_CORBO_GUI_LABEL_SLIDER_WIDGET_H_
27 
28 #include <QLabel>
29 #include <QSlider>
30 
31 #include <limits>
32 
33 namespace corbo {
34 namespace gui {
35 
36 class LabelSliderWidget : public QWidget
37 {
38  Q_OBJECT
39 
40  public:
41  explicit LabelSliderWidget(QWidget* parent = 0) : LabelSliderWidget("", 0.0, 1, 2, parent) {}
42 
43  LabelSliderWidget(const QString& label, double default_value, int resolution = 1, int display_decimal_places = 2, QWidget* parent = 0);
45 
46  QSize sizeHint() const override;
47 
48  void setLabel(const QString& label) { _label->setText(label); }
49  void setValue(double value);
50 
51  void setResolution(int resolution) { _resolution = resolution; }
52 
53  void setMinMax(double min, double max);
54 
55  void setDisplayDecimalPlaces(int num_places) { _decimal_places = num_places; }
56 
57  QSlider* widgetSlider() { return _slider; }
58  const QSlider* widgetSlider() const { return _slider; }
59 
60  QLabel* widgetLabel() { return _label; }
61  const QLabel* widgetLabel() const { return _label; }
62 
63  signals:
64  void valueChanged(double value);
65 
66  private slots:
67  void updateDisplay(int value);
68 
69  private:
70  QSlider* _slider;
71  QLabel* _label;
72  QLabel* _display;
73  int _resolution = 1;
74  int _decimal_places = 2;
77 };
78 
79 } // namespace gui
80 } // namespace corbo
81 
82 #endif // SRC_GUI_INCLUDE_CORBO_GUI_LABEL_SLIDER_WIDGET_H_
corbo::gui::LabelSliderWidget::widgetLabel
QLabel * widgetLabel()
Definition: label_slider_widget.h:126
corbo::gui::LabelSliderWidget::_label
QLabel * _label
Definition: label_slider_widget.h:137
corbo
Definition: communication/include/corbo-communication/utilities.h:37
corbo::gui::LabelSliderWidget::setResolution
void setResolution(int resolution)
Definition: label_slider_widget.h:117
corbo::gui::LabelSliderWidget::setLabel
void setLabel(const QString &label)
Definition: label_slider_widget.h:114
corbo::gui::LabelSliderWidget::sizeHint
QSize sizeHint() const override
Definition: label_slider_widget.cpp:99
corbo::gui::LabelSliderWidget::_min_dbl_value
double _min_dbl_value
Definition: label_slider_widget.h:141
corbo::gui::LabelSliderWidget::updateDisplay
void updateDisplay(int value)
Definition: label_slider_widget.cpp:116
corbo::gui::LabelSliderWidget::widgetSlider
QSlider * widgetSlider()
Definition: label_slider_widget.h:123
corbo::gui::LabelSliderWidget::setValue
void setValue(double value)
Definition: label_slider_widget.cpp:101
corbo::gui::LabelSliderWidget::setMinMax
void setMinMax(double min, double max)
Definition: label_slider_widget.cpp:108
corbo::gui::LabelSliderWidget::_resolution
int _resolution
Definition: label_slider_widget.h:139
corbo::gui::LabelSliderWidget::_display
QLabel * _display
Definition: label_slider_widget.h:138
min
#define min(a, b)
Definition: datatypes.h:19
corbo::gui::LabelSliderWidget::valueChanged
void valueChanged(double value)
corbo::gui::LabelSliderWidget::_decimal_places
int _decimal_places
Definition: label_slider_widget.h:140
max
#define max(a, b)
Definition: datatypes.h:20
corbo::gui::LabelSliderWidget::_max_dbl_value
double _max_dbl_value
Definition: label_slider_widget.h:142
corbo::gui::LabelSliderWidget::~LabelSliderWidget
~LabelSliderWidget()
Definition: label_slider_widget.h:110
corbo::gui::LabelSliderWidget::_slider
QSlider * _slider
Definition: label_slider_widget.h:136
corbo::gui::LabelSliderWidget::setDisplayDecimalPlaces
void setDisplayDecimalPlaces(int num_places)
Definition: label_slider_widget.h:121
corbo::gui::LabelSliderWidget::LabelSliderWidget
LabelSliderWidget(QWidget *parent=0)
Definition: label_slider_widget.h:107


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