Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquickrangeslider_p.h
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QQUICKRANGESLIDER_P_H
6#define QQUICKRANGESLIDER_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtQuickTemplates2/private/qquickcontrol_p.h>
20
21QT_BEGIN_NAMESPACE
22
23class QQuickRangeSliderPrivate;
24class QQuickRangeSliderNode;
25
26class Q_QUICKTEMPLATES2_EXPORT QQuickRangeSlider : public QQuickControl
27{
28 Q_OBJECT
29 Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged FINAL)
30 Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged FINAL)
31 Q_PROPERTY(QQuickRangeSliderNode *first READ first CONSTANT FINAL)
32 Q_PROPERTY(QQuickRangeSliderNode *second READ second CONSTANT FINAL)
33 Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL)
34 Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL)
35 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL)
36 // 2.2 (Qt 5.9)
37 Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION(2, 2))
38 Q_PROPERTY(bool horizontal READ isHorizontal NOTIFY orientationChanged FINAL REVISION(2, 3))
39 // 2.3 (Qt 5.10)
40 Q_PROPERTY(bool vertical READ isVertical NOTIFY orientationChanged FINAL REVISION(2, 3))
41 // 2.5 (Qt 5.12)
42 Q_PROPERTY(qreal touchDragThreshold READ touchDragThreshold WRITE setTouchDragThreshold RESET resetTouchDragThreshold NOTIFY touchDragThresholdChanged FINAL REVISION(2, 5))
43 QML_NAMED_ELEMENT(RangeSlider)
44 QML_ADDED_IN_VERSION(2, 0)
45
46public:
47 explicit QQuickRangeSlider(QQuickItem *parent = nullptr);
48 ~QQuickRangeSlider();
49
50 qreal from() const;
51 void setFrom(qreal from);
52
53 qreal to() const;
54 void setTo(qreal to);
55
56 QQuickRangeSliderNode *first() const;
57 QQuickRangeSliderNode *second() const;
58
59 qreal stepSize() const;
60 void setStepSize(qreal step);
61
62 enum SnapMode {
63 NoSnap,
64 SnapAlways,
65 SnapOnRelease
66 };
67 Q_ENUM(SnapMode)
68
69 SnapMode snapMode() const;
70 void setSnapMode(SnapMode mode);
71
72 Qt::Orientation orientation() const;
73 void setOrientation(Qt::Orientation orientation);
74
75 Q_INVOKABLE void setValues(qreal firstValue, qreal secondValue);
76
77 // 2.2 (Qt 5.9)
78 bool live() const;
79 void setLive(bool live);
80
81 // 2.3 (Qt 5.10)
82 bool isHorizontal() const;
83 bool isVertical() const;
84
85 // 2.5 (Qt 5.12)
86 qreal touchDragThreshold() const;
87 void setTouchDragThreshold(qreal touchDragThreshold);
88 void resetTouchDragThreshold();
89 Q_REVISION(2, 5) Q_INVOKABLE qreal valueAt(qreal position) const;
90
91Q_SIGNALS:
92 void fromChanged();
93 void toChanged();
94 void stepSizeChanged();
95 void snapModeChanged();
96 void orientationChanged();
97 // 2.2 (Qt 5.9)
98 Q_REVISION(2, 2) void liveChanged();
99 // 2.5 (Qt 5.12)
100 Q_REVISION(2, 5) void touchDragThresholdChanged();
101
102protected:
103 void focusInEvent(QFocusEvent *event) override;
104 void hoverEnterEvent(QHoverEvent *event) override;
105 void hoverMoveEvent(QHoverEvent *event) override;
106 void hoverLeaveEvent(QHoverEvent *event) override;
107 void keyPressEvent(QKeyEvent *event) override;
108 void keyReleaseEvent(QKeyEvent *event) override;
109 void mousePressEvent(QMouseEvent *event) override;
110#if QT_CONFIG(quicktemplates2_multitouch)
111 void touchEvent(QTouchEvent *event) override;
112#endif
113 void mirrorChange() override;
114 void classBegin() override;
115 void componentComplete() override;
116
117#if QT_CONFIG(accessibility)
118 QAccessible::Role accessibleRole() const override;
119#endif
120
121private:
122 friend class QQuickRangeSliderNode;
123
124 Q_DISABLE_COPY(QQuickRangeSlider)
125 Q_DECLARE_PRIVATE(QQuickRangeSlider)
126};
127
129
130class Q_QUICKTEMPLATES2_EXPORT QQuickRangeSliderNode : public QObject
131{
132 Q_OBJECT
133 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL)
134 Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
135 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
136 Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
137 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
138 // 2.1 (Qt 5.8)
139 Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION(2, 1))
140 // 2.5 (Qt 5.12)
141 Q_PROPERTY(qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL REVISION(2, 5))
142 Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY implicitHandleHeightChanged FINAL REVISION(2, 5))
143 Q_CLASSINFO("DeferredPropertyNames", "handle")
144 QML_ANONYMOUS
145 QML_ADDED_IN_VERSION(2, 0)
146
147public:
148 explicit QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider);
149 ~QQuickRangeSliderNode();
150
151 qreal value() const;
152 void setValue(qreal value);
153
154 qreal position() const;
155 qreal visualPosition() const;
156
157 QQuickItem *handle() const;
158 void setHandle(QQuickItem *handle);
159
160 bool isPressed() const;
161 void setPressed(bool pressed);
162
163 // 2.1 (Qt 5.8)
164 bool isHovered() const;
165 void setHovered(bool hovered);
166
167 // 2.5 (Qt 5.12)
168 qreal implicitHandleWidth() const;
169 qreal implicitHandleHeight() const;
170
171public Q_SLOTS:
172 void increase();
173 void decrease();
174
175Q_SIGNALS:
176 void valueChanged();
177 void positionChanged();
178 void visualPositionChanged();
179 void handleChanged();
180 void pressedChanged();
181 // 2.1 (Qt 5.8)
182 Q_REVISION(2, 1) void hoveredChanged();
183 // 2.5 (Qt 5.12)
184 /*Q_REVISION(2, 5)*/ void moved();
185 /*Q_REVISION(2, 5)*/ void implicitHandleWidthChanged();
186 /*Q_REVISION(2, 5)*/ void implicitHandleHeightChanged();
187
188private:
189 Q_DISABLE_COPY(QQuickRangeSliderNode)
190 Q_DECLARE_PRIVATE(QQuickRangeSliderNode)
191};
192
193QT_END_NAMESPACE
194
195#endif // QQUICKRANGESLIDER_P_H
Used to select a range of values by sliding two handles along a track.
void setPosition(qreal position, bool ignoreOtherPosition=false)
void executeHandle(bool complete=false)
static QQuickRangeSliderNodePrivate * get(QQuickRangeSliderNode *node)
QQuickDeferredPointer< QQuickItem > handle
void updatePosition(bool ignoreOtherPosition=false)
bool handleMove(const QPointF &point, ulong timestamp) override
void itemDestroyed(QQuickItem *item) override
bool handleRelease(const QPointF &point, ulong timestamp) override
QQuickRangeSliderNode * first
void itemImplicitHeightChanged(QQuickItem *item) override
bool handlePress(const QPointF &point, ulong timestamp) override
void updateHover(const QPointF &pos)
QQuickRangeSliderNode * second
void itemImplicitWidthChanged(QQuickItem *item) override
static const qreal defaultFrom
static const qreal defaultTo
static qreal valueAt(const QQuickRangeSlider *slider, qreal position)
static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPointF &point)
static qreal snapPosition(const QQuickRangeSlider *slider, qreal position)