VAPOR3 3.9.4
Combo.h
Go to the documentation of this file.
1#ifndef COMBO_H
2#define COMBO_H
3
4#include <QWidget>
5#include <QLineEdit>
6#include <QSlider>
7#include <QValidator>
8
9// Fix for Qt bug https://bugreports.qt.io/browse/QTBUG-98093
10// Apply a style sheet to QSlider to make it work on OSX Monterey
11#ifdef Darwin
12 #include "QMontereySlider.h"
13 #define QSlider QMontereySlider
14#endif
15
16// class Combo
17//
18// Manages a paired QSlider and QLineEdit class, synchronizing values
19// across both such that a single value is represented. The value
20// must be within a specified range.
21//
22class Combo : public QWidget {
23 Q_OBJECT
24
25public:
26 Combo(QLineEdit *edit, QSlider *slider, bool intType = false);
27
28 // This method must be called whenever the minimax or maximum allowable
29 // valid value changes, or the current value
30 // is changed externally. I.e. Update() provides a means to change
31 // the internal state of the class. If minValid > maxValid, maxValid
32 // will be set to minValid. If value is outside of minValid and maxValid
33 // it will be set to minValid.
34 //
35 void Update(double minValid, double maxValid, double value);
36
37 void Update(double value) { Update(_minValid, _maxValid, value); }
38
39 // Returns a pointer the QSlider object
40 //
41 QSlider *GetSlider() const { return (_slider); };
42
43 // Returns a pointer the QLineEdit object
44 //
45 QLineEdit *GetLineEdit() const { return (_lineEdit); };
46
47 // Returns the currently set value
48 //
49 double GetValue() const { return (_value); };
50
51 // Set how many digits to show for floating-point precision
52 // This setting won't change anything for displaying integers.
53 // The input precision value should be at least 1.
54 //
55 void SetPrecision(int precision);
56
57 // switch IntType
58 void SetIntType(bool);
59
60 void SetEnabled(bool);
61
62private slots:
63 // Slot for QLineEdit events
64 //
65 void setLineEdit();
66
67 // Slot for QSlider events
68 //
69 void setSlider();
70 void setSliderMini(int pos);
71
72public slots:
73 // Public slot for changing the class's value
74 //
75 void SetSliderLineEdit(double);
76
77signals:
78 // This signal is emitted whenever the value of the class changes
79 //
80 void valueChanged(double value);
81 void valueChanged(int value);
82
83private:
84 double _minValid;
85 double _maxValid;
86 double _value;
87 bool _intType;
88 int _floatPrecision; // how many digits after the decimal point?
89
90 QLineEdit * _lineEdit;
91 QValidator *_lineEditValidator;
92 QSlider * _slider;
93};
94
95#endif
Definition: Combo.h:22
void Update(double minValid, double maxValid, double value)
void SetSliderLineEdit(double)
void Update(double value)
Definition: Combo.h:37
void valueChanged(int value)
void SetEnabled(bool)
double GetValue() const
Definition: Combo.h:49
void valueChanged(double value)
void SetIntType(bool)
Combo(QLineEdit *edit, QSlider *slider, bool intType=false)
QLineEdit * GetLineEdit() const
Definition: Combo.h:45
void SetPrecision(int precision)
QSlider * GetSlider() const
Definition: Combo.h:41