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 // 6.12 (Qt 6.12)
44 Q_PROPERTY(bool crossingEnabled READ isCrossingEnabled WRITE setCrossingEnabled NOTIFY crossingEnabledChanged FINAL REVISION(6, 12))
45 Q_PROPERTY(bool handlesCrossed READ handlesCrossed NOTIFY handlesCrossedChanged FINAL REVISION(6, 12))
46 Q_PROPERTY(qreal effectiveFirstValue READ effectiveFirstValue NOTIFY effectiveFirstValueChanged FINAL REVISION(6, 12))
47 Q_PROPERTY(qreal effectiveSecondValue READ effectiveSecondValue NOTIFY effectiveSecondValueChanged FINAL REVISION(6, 12))
48 QML_NAMED_ELEMENT(RangeSlider)
49 QML_ADDED_IN_VERSION(2, 0)
50
51public:
52 explicit QQuickRangeSlider(QQuickItem *parent = nullptr);
53 ~QQuickRangeSlider();
54
55 qreal from() const;
56 void setFrom(qreal from);
57
58 qreal to() const;
59 void setTo(qreal to);
60
61 QQuickRangeSliderNode *first() const;
62 QQuickRangeSliderNode *second() const;
63
64 qreal stepSize() const;
65 void setStepSize(qreal step);
66
67 enum SnapMode {
68 NoSnap,
69 SnapAlways,
70 SnapOnRelease
71 };
72 Q_ENUM(SnapMode)
73
74 SnapMode snapMode() const;
75 void setSnapMode(SnapMode mode);
76
77 Qt::Orientation orientation() const;
78 void setOrientation(Qt::Orientation orientation);
79
80 Q_INVOKABLE void setValues(qreal firstValue, qreal secondValue);
81
82 // 2.2 (Qt 5.9)
83 bool live() const;
84 void setLive(bool live);
85
86 // 2.3 (Qt 5.10)
87 bool isHorizontal() const;
88 bool isVertical() const;
89
90 // 2.5 (Qt 5.12)
91 qreal touchDragThreshold() const;
92 void setTouchDragThreshold(qreal touchDragThreshold);
93 void resetTouchDragThreshold();
94 Q_REVISION(2, 5) Q_INVOKABLE qreal valueAt(qreal position) const;
95
96 // 6.12 (Qt 6.12)
97 bool isCrossingEnabled() const;
98 void setCrossingEnabled(bool enabled);
99 bool handlesCrossed() const;
100 qreal effectiveFirstValue() const;
101 qreal effectiveSecondValue() const;
102
103Q_SIGNALS:
104 void fromChanged();
105 void toChanged();
106 void stepSizeChanged();
107 void snapModeChanged();
108 void orientationChanged();
109 // 2.2 (Qt 5.9)
110 Q_REVISION(2, 2) void liveChanged();
111 // 2.5 (Qt 5.12)
112 Q_REVISION(2, 5) void touchDragThresholdChanged();
113 // 6.12 (Qt 6.12)
114 Q_REVISION(6, 12) void crossingEnabledChanged();
115 Q_REVISION(6, 12) void handlesCrossedChanged();
116 Q_REVISION(6, 12) void effectiveFirstValueChanged();
117 Q_REVISION(6, 12) void effectiveSecondValueChanged();
118
119protected:
120 void focusInEvent(QFocusEvent *event) override;
121 void hoverEnterEvent(QHoverEvent *event) override;
122 void hoverMoveEvent(QHoverEvent *event) override;
123 void hoverLeaveEvent(QHoverEvent *event) override;
124 void keyPressEvent(QKeyEvent *event) override;
125 void keyReleaseEvent(QKeyEvent *event) override;
126 void mousePressEvent(QMouseEvent *event) override;
127#if QT_CONFIG(quicktemplates2_multitouch)
128 void touchEvent(QTouchEvent *event) override;
129#endif
130 void mirrorChange() override;
131 void classBegin() override;
132 void componentComplete() override;
133
134#if QT_CONFIG(accessibility)
135 QAccessible::Role accessibleRole() const override;
136#endif
137
138private:
139 friend class QQuickRangeSliderNode;
140 void updateHandleCrossing();
141 void effectiveValueChange(QQuickRangeSliderNode* node);
142 void updateFocusOrder();
143
144 Q_DISABLE_COPY(QQuickRangeSlider)
145 Q_DECLARE_PRIVATE(QQuickRangeSlider)
146};
147
149
150class Q_QUICKTEMPLATES2_EXPORT QQuickRangeSliderNode : public QObject
151{
152 Q_OBJECT
153 Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL)
154 Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL)
155 Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL)
156 Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL)
157 Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL)
158 // 2.1 (Qt 5.8)
159 Q_PROPERTY(bool hovered READ isHovered WRITE setHovered NOTIFY hoveredChanged FINAL REVISION(2, 1))
160 // 2.5 (Qt 5.12)
161 Q_PROPERTY(qreal implicitHandleWidth READ implicitHandleWidth NOTIFY implicitHandleWidthChanged FINAL REVISION(2, 5))
162 Q_PROPERTY(qreal implicitHandleHeight READ implicitHandleHeight NOTIFY implicitHandleHeightChanged FINAL REVISION(2, 5))
163 Q_CLASSINFO("DeferredPropertyNames", "handle")
164 QML_ANONYMOUS
165 QML_ADDED_IN_VERSION(2, 0)
166
167public:
168 explicit QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider);
169 ~QQuickRangeSliderNode();
170
171 qreal value() const;
172 void setValue(qreal value);
173
174 qreal position() const;
175 qreal visualPosition() const;
176
177 QQuickItem *handle() const;
178 void setHandle(QQuickItem *handle);
179
180 bool isPressed() const;
181 void setPressed(bool pressed);
182
183 // 2.1 (Qt 5.8)
184 bool isHovered() const;
185 void setHovered(bool hovered);
186
187 // 2.5 (Qt 5.12)
188 qreal implicitHandleWidth() const;
189 qreal implicitHandleHeight() const;
190
191public Q_SLOTS:
192 void increase();
193 void decrease();
194
195Q_SIGNALS:
196 void valueChanged();
197 void positionChanged();
198 void visualPositionChanged();
199 void handleChanged();
200 void pressedChanged();
201 // 2.1 (Qt 5.8)
202 Q_REVISION(2, 1) void hoveredChanged();
203 // 2.5 (Qt 5.12)
204 /*Q_REVISION(2, 5)*/ void moved();
205 /*Q_REVISION(2, 5)*/ void implicitHandleWidthChanged();
206 /*Q_REVISION(2, 5)*/ void implicitHandleHeightChanged();
207
208private:
209 void updateHandleCrossing();
210
211 Q_DISABLE_COPY(QQuickRangeSliderNode)
212 Q_DECLARE_PRIVATE(QQuickRangeSliderNode)
213};
214
215QT_END_NAMESPACE
216
217#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 * pressedNode(int touchId=-1) const
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
Combined button and popup list for selecting options.
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)