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_
#define max(a, b)
Definition: datatypes.h:20
const QSlider * widgetSlider() const
#define min(a, b)
Definition: datatypes.h:19
void setResolution(int resolution)
void setMinMax(double min, double max)
void setLabel(const QString &label)
void valueChanged(double value)
LabelSliderWidget(QWidget *parent=0)
void setDisplayDecimalPlaces(int num_places)
const QLabel * widgetLabel() const


control_box_rst
Author(s): Christoph Rösmann
autogenerated on Mon Feb 28 2022 22:06:57