pqDoubleSliderWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 #ifndef pqDoubleSliderWidget_h
4 #define pqDoubleSliderWidget_h
5 
6 #include "pqDoubleLineEdit.h"
7 #include "pqWidgetsModule.h"
8 #include <QWidget>
9 
10 class QDoubleValidator;
11 class QSlider;
12 
16 class PQWIDGETS_EXPORT pqDoubleSliderWidget : public QWidget
17 {
18  Q_OBJECT
19  Q_PROPERTY(double value READ value WRITE setValue USER true)
20  Q_PROPERTY(pqDoubleLineEdit::RealNumberNotation notation READ notation WRITE setNotation)
21  Q_PROPERTY(int precision READ precision WRITE setPrecision)
22  Q_PROPERTY(bool useGlobalPrecisionAndNotation READ useGlobalPrecisionAndNotation WRITE
23  setUseGlobalPrecisionAndNotation)
24 public:
25  pqDoubleSliderWidget(QWidget* parent = nullptr);
26  ~pqDoubleSliderWidget() override;
27 
31  double value() const;
32 
37  pqDoubleLineEdit::RealNumberNotation notation() const;
38 
43  int precision() const;
44 
50  bool useGlobalPrecisionAndNotation() const;
51 
52 Q_SIGNALS:
56  void valueChanged(double);
57 
64  void valueEdited(double);
65 
66 public Q_SLOTS:
70  void setValue(double val);
71 
76  void setNotation(pqDoubleLineEdit::RealNumberNotation _notation);
77 
82  void setPrecision(int precision);
83 
88  void setUseGlobalPrecisionAndNotation(bool value);
89 
90 protected:
91  virtual int valueToSliderPos(double val);
92  virtual double sliderPosToValue(int pos);
93  void setValidator(QDoubleValidator* validator);
94  const QDoubleValidator* validator() const;
95  void setSliderRange(int min, int max);
96  void updateSlider();
97 
98 private Q_SLOTS:
99  void sliderChanged(int val);
100  void textChanged(const QString& text);
101  void editingFinished();
102  void sliderPressed();
103  void sliderReleased();
104  void emitValueEdited();
105  void emitIfDeferredValueEdited();
106 
107 private: // NOLINT(readability-redundant-access-specifiers)
108  double Value;
109  QSlider* Slider;
110  pqDoubleLineEdit* DoubleLineEdit;
111  bool BlockUpdate;
112  bool InteractingWithSlider;
113  bool DeferredValueEdited;
114 };
115 
116 #endif
A widget with a tied slider and line edit for editing a double property.
#define PQWIDGETS_EXPORT
pqLineEdit subclass that supports a low precision view when inactive
#define const
Definition: zconf.h:238