Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickrangeslider.cpp
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
5#include "qquickcontrol_p_p.h"
7
8#include <QtCore/qscopedpointer.h>
9#include <QtQuick/private/qquickwindow_p.h>
10
12
17
63{
64 Q_DECLARE_PUBLIC(QQuickRangeSliderNode)
65public:
71
72 bool isFirst() const;
73
74 void setPosition(qreal position, bool ignoreOtherPosition = false);
75 void updatePosition(bool ignoreOtherPosition = false);
76
77 void cancelHandle();
78 void executeHandle(bool complete = false);
79
81
83 bool isPendingValue = false;
86 QQuickDeferredPointer<QQuickItem> handle;
88 bool pressed = false;
89 bool hovered = false;
90 int touchId = -1;
91};
92
94{
95 return this == get(slider->first());
96}
97
99{
101
102 const qreal min = isFirst() || ignoreOtherPosition ? 0.0 : qMax<qreal>(0.0, slider->first()->position());
103 const qreal max = !isFirst() || ignoreOtherPosition ? 1.0 : qMin<qreal>(1.0, slider->second()->position());
104 position = qBound(min, position, max);
105 if (!qFuzzyCompare(this->position, position)) {
106 this->position = position;
107 emit q->positionChanged();
108 emit q->visualPositionChanged();
109 }
110}
111
113{
114 qreal pos = 0;
115 if (!qFuzzyCompare(slider->from(), slider->to()))
116 pos = (value - slider->from()) / (slider->to() - slider->from());
117 setPosition(pos, ignoreOtherPosition);
118}
119
125
127{
129 if (handle.wasExecuted())
130 return;
131
132 if (!handle || complete)
134 if (complete)
136}
137
142
147
151
153{
154 Q_D(const QQuickRangeSliderNode);
155 return d->value;
156}
157
159{
161 if (!d->slider->isComponentComplete()) {
162 d->pendingValue = value;
163 d->isPendingValue = true;
164 return;
165 }
166
167 // First, restrict the first value to be within to and from.
168 const qreal smaller = qMin(d->slider->to(), d->slider->from());
169 const qreal larger = qMax(d->slider->to(), d->slider->from());
170 value = qBound(smaller, value, larger);
171
172 // Then, ensure that it doesn't go past the other value,
173 // a check that depends on whether or not the range is inverted.
174 const bool invertedRange = d->slider->from() > d->slider->to();
175 if (d->isFirst()) {
176 if (invertedRange) {
177 if (value < d->slider->second()->value())
178 value = d->slider->second()->value();
179 } else {
180 if (value > d->slider->second()->value())
181 value = d->slider->second()->value();
182 }
183 } else {
184 if (invertedRange) {
185 if (value > d->slider->first()->value())
186 value = d->slider->first()->value();
187 } else {
188 if (value < d->slider->first()->value())
189 value = d->slider->first()->value();
190 }
191 }
192
193 if (!qFuzzyCompare(d->value, value)) {
194 d->value = value;
195 d->updatePosition();
197 }
198}
199
201{
202 Q_D(const QQuickRangeSliderNode);
203 return d->position;
204}
205
207{
208 Q_D(const QQuickRangeSliderNode);
209 if (d->slider->orientation() == Qt::Vertical || d->slider->isMirrored())
210 return 1.0 - d->position;
211 return d->position;
212}
213
215{
217 if (!d->handle)
218 d->executeHandle();
219 return d->handle;
220}
221
223{
225 if (d->handle == handle)
226 return;
227
229
230 if (!d->handle.isExecuting())
231 d->cancelHandle();
232
233 const qreal oldImplicitHandleWidth = implicitHandleWidth();
234 const qreal oldImplicitHandleHeight = implicitHandleHeight();
235
236 QQuickControlPrivate::get(d->slider)->removeImplicitSizeListener(d->handle);
238 d->handle = handle;
239
240 if (handle) {
241 if (!handle->parentItem())
242 handle->setParentItem(d->slider);
243
244 QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle;
245 QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle;
246 if (firstHandle && secondHandle) {
247 // The order of property assignments in QML is undefined,
248 // but we need the first handle to be before the second due
249 // to focus order constraints, so check for that here.
250 const QList<QQuickItem *> childItems = d->slider->childItems();
251 const int firstIndex = childItems.indexOf(firstHandle);
252 const int secondIndex = childItems.indexOf(secondHandle);
253 if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
254 firstHandle->stackBefore(secondHandle);
255 // Ensure we have some way of knowing which handle is above
256 // the other when it comes to mouse presses, and also that
257 // they are rendered in the correct order.
258 secondHandle->setZ(secondHandle->z() + 1);
259 }
260 }
261
262 handle->setActiveFocusOnTab(true);
263 QQuickControlPrivate::get(d->slider)->addImplicitSizeListener(handle);
264 }
265
266 if (!qFuzzyCompare(oldImplicitHandleWidth, implicitHandleWidth()))
268 if (!qFuzzyCompare(oldImplicitHandleHeight, implicitHandleHeight()))
270 if (!d->handle.isExecuting())
272}
273
275{
276 Q_D(const QQuickRangeSliderNode);
277 return d->pressed;
278}
279
281{
283 if (d->pressed == pressed)
284 return;
285
286 d->pressed = pressed;
287 d->slider->setAccessibleProperty("pressed", pressed || d->slider->second()->isPressed());
289}
290
292{
293 Q_D(const QQuickRangeSliderNode);
294 return d->hovered;
295}
296
298{
300 if (d->hovered == hovered)
301 return;
302
303 d->hovered = hovered;
304 emit hoveredChanged();
305}
306
308{
309 Q_D(const QQuickRangeSliderNode);
310 if (!d->handle)
311 return 0;
312 return d->handle->implicitWidth();
313}
314
316{
317 Q_D(const QQuickRangeSliderNode);
318 if (!d->handle)
319 return 0;
320 return d->handle->implicitHeight();
321}
322
324{
326 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
327 setValue(d->value + step);
328}
329
331{
333 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
334 setValue(d->value - step);
335}
336
337static const qreal defaultFrom = 0.0;
338static const qreal defaultTo = 1.0;
339
341{
342 Q_DECLARE_PUBLIC(QQuickRangeSlider)
343
344public:
346
347#if QT_CONFIG(quicktemplates2_multitouch)
348 bool acceptTouch(const QTouchEvent::TouchPoint &point) override;
349#endif
350 bool handlePress(const QPointF &point, ulong timestamp) override;
351 bool handleMove(const QPointF &point, ulong timestamp) override;
352 bool handleRelease(const QPointF &point, ulong timestamp) override;
353 void handleUngrab() override;
354
355 void updateHover(const QPointF &pos);
356
359 void itemDestroyed(QQuickItem *item) override;
360
361 bool live = true;
371};
372
374{
375 return slider->from() + (slider->to() - slider->from()) * position;
376}
377
379{
380 const qreal range = slider->to() - slider->from();
381 if (qFuzzyIsNull(range))
382 return position;
383
384 const qreal effectiveStep = slider->stepSize() / range;
385 if (qFuzzyIsNull(effectiveStep))
386 return position;
387
388 return qRound(position / effectiveStep) * effectiveStep;
389}
390
391static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPointF &point)
392{
393 if (slider->orientation() == Qt::Horizontal) {
394 const qreal hw = handle ? handle->width() : 0;
395 const qreal offset = hw / 2;
396 const qreal extent = slider->availableWidth() - hw;
397 if (!qFuzzyIsNull(extent)) {
398 if (slider->isMirrored())
399 return (slider->width() - point.x() - slider->rightPadding() - offset) / extent;
400 return (point.x() - slider->leftPadding() - offset) / extent;
401 }
402 } else {
403 const qreal hh = handle ? handle->height() : 0;
404 const qreal offset = hh / 2;
405 const qreal extent = slider->availableHeight() - hh;
406 if (!qFuzzyIsNull(extent))
407 return (slider->height() - point.y() - slider->bottomPadding() - offset) / extent;
408 }
409 return 0;
410}
411
413{
414 if (touchId == -1)
415 return first->isPressed() ? first : (second->isPressed() ? second : nullptr);
417 return first;
419 return second;
420 return nullptr;
421}
422
423#if QT_CONFIG(quicktemplates2_multitouch)
424bool QQuickRangeSliderPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
425{
426 int firstId = QQuickRangeSliderNodePrivate::get(first)->touchId;
427 int secondId = QQuickRangeSliderNodePrivate::get(second)->touchId;
428
429 if (((firstId == -1 || secondId == -1) && point.state() == QEventPoint::Pressed) || point.id() == firstId || point.id() == secondId) {
430 touchId = point.id();
431 return true;
432 }
433
434 return false;
435}
436#endif
437
439{
441 QQuickControlPrivate::handlePress(point, timestamp);
442 pressPoint = point;
443
444 QQuickItem *firstHandle = first->handle();
445 QQuickItem *secondHandle = second->handle();
446 const bool firstHit = firstHandle && !first->isPressed() && firstHandle->contains(q->mapToItem(firstHandle, point));
447 const bool secondHit = secondHandle && !second->isPressed() && secondHandle->contains(q->mapToItem(secondHandle, point));
448 QQuickRangeSliderNode *hitNode = nullptr;
449 QQuickRangeSliderNode *otherNode = nullptr;
450
451 if (firstHit && secondHit) {
452 // choose highest
453 hitNode = firstHandle->z() > secondHandle->z() ? first : second;
454 otherNode = firstHandle->z() > secondHandle->z() ? second : first;
455 } else if (firstHit) {
456 hitNode = first;
457 otherNode = second;
458 } else if (secondHit) {
459 hitNode = second;
460 otherNode = first;
461 } else {
462 // find the nearest
463 const qreal firstPos = positionAt(q, firstHandle, point);
464 const qreal secondPos = positionAt(q, secondHandle, point);
465 const qreal firstDistance = qAbs(firstPos - first->position());
466 const qreal secondDistance = qAbs(secondPos - second->position());
467
468 if (qFuzzyCompare(firstDistance, secondDistance)) {
469 // same distance => choose the one that can be moved towards the press position
470 const bool inverted = from > to;
471 if ((!inverted && firstPos < first->position()) || (inverted && firstPos > first->position())) {
472 hitNode = first;
473 otherNode = second;
474 } else {
475 hitNode = second;
476 otherNode = first;
477 }
478 } else if (firstDistance < secondDistance) {
479 hitNode = first;
480 otherNode = second;
481 } else {
482 hitNode = second;
483 otherNode = first;
484 }
485 }
486
487 if (hitNode) {
488 hitNode->setPressed(true);
489 if (QQuickItem *handle = hitNode->handle()) {
490 handle->setZ(1);
491
492 // A specific handle was hit, so it should get focus, rather than the default
493 // (first handle) that gets focus whenever the RangeSlider itself does - see focusInEvent().
495 handle->forceActiveFocus(Qt::MouseFocusReason);
496 }
497 QQuickRangeSliderNodePrivate::get(hitNode)->touchId = touchId;
498 }
499 if (otherNode) {
500 if (QQuickItem *handle = otherNode->handle())
501 handle->setZ(0);
502 }
503 return true;
504}
505
507{
509 QQuickControlPrivate::handleMove(point, timestamp);
511 if (pressedNode) {
512 const qreal oldPos = pressedNode->position();
513 qreal pos = positionAt(q, pressedNode->handle(), point);
515 pos = snapPosition(q, pos);
516 if (live)
518 else
520
521 if (!qFuzzyCompare(pressedNode->position(), oldPos))
523 }
524 return true;
525}
526
528{
530 QQuickControlPrivate::handleRelease(point, timestamp);
532
534 if (!pressedNode)
535 return true;
537
538 const qreal oldPos = pressedNode->position();
539 qreal pos = positionAt(q, pressedNode->handle(), point);
541 pos = snapPosition(q, pos);
542 qreal val = valueAt(q, pos);
546 pressedNodePrivate->setPosition(pos);
547 q->setKeepMouseGrab(false);
548 q->setKeepTouchGrab(false);
549
550 if (!qFuzzyCompare(pressedNode->position(), oldPos))
552
553 pressedNode->setPressed(false);
554 pressedNodePrivate->touchId = -1;
555 return true;
556}
557
567
569{
571 QQuickItem *firstHandle = first->handle();
572 QQuickItem *secondHandle = second->handle();
573 bool firstHandleHovered = firstHandle && firstHandle->isEnabled()
574 && firstHandle->contains(q->mapToItem(firstHandle, pos));
575 bool secondHandleHovered = secondHandle && secondHandle->isEnabled()
576 && secondHandle->contains(q->mapToItem(secondHandle, pos));
577
578 if (firstHandleHovered && secondHandleHovered) {
579 // Only hover the handle with the higher Z value.
580 const bool firstHandleHasHigherZ = firstHandle->z() > secondHandle->z();
581 firstHandleHovered = firstHandleHasHigherZ;
582 secondHandleHovered = !firstHandleHasHigherZ;
583 }
584 first->setHovered(firstHandleHovered);
585 second->setHovered(secondHandleHovered);
586}
587
596
605
607{
609 if (item == first->handle())
610 first->setHandle(nullptr);
611 else if (item == second->handle())
612 second->setHandle(nullptr);
613}
614
617{
619 d->first = new QQuickRangeSliderNode(0.0, this);
620 d->second = new QQuickRangeSliderNode(1.0, this);
622
624#ifdef Q_OS_MACOS
626#else
628#endif
630#if QT_CONFIG(quicktemplates2_multitouch)
632#endif
633#if QT_CONFIG(cursor)
635#endif
636}
637
639{
641 d->removeImplicitSizeListener(d->first->handle());
642 d->removeImplicitSizeListener(d->second->handle());
643}
644
653{
654 Q_D(const QQuickRangeSlider);
655 return d->from;
656}
657
659{
661 if (qFuzzyCompare(d->from, from))
662 return;
663
664 d->from = from;
666
667 if (isComponentComplete()) {
668 d->first->setValue(d->first->value());
669 d->second->setValue(d->second->value());
670 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
671 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
672 firstPrivate->updatePosition(true);
673 secondPrivate->updatePosition();
674 }
675}
676
685{
686 Q_D(const QQuickRangeSlider);
687 return d->to;
688}
689
691{
693 if (qFuzzyCompare(d->to, to))
694 return;
695
696 d->to = to;
697 emit toChanged();
698
699 if (isComponentComplete()) {
700 d->first->setValue(d->first->value());
701 d->second->setValue(d->second->value());
702 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
703 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
704 firstPrivate->updatePosition(true);
705 secondPrivate->updatePosition();
706 }
707}
708
721{
722 Q_D(const QQuickRangeSlider);
723 return d->touchDragThreshold;
724}
725
727{
729 if (d->touchDragThreshold == touchDragThreshold)
730 return;
731
732 d->touchDragThreshold = touchDragThreshold;
733 emit touchDragThresholdChanged();
734}
735
740
749qreal QQuickRangeSlider::valueAt(qreal position) const
750{
751 Q_D(const QQuickRangeSlider);
752 const qreal value = (d->to - d->from) * position;
753 if (qFuzzyIsNull(d->stepSize))
754 return d->from + value;
755 return d->from + qRound(value / d->stepSize) * d->stepSize;
756}
757
820{
821 Q_D(const QQuickRangeSlider);
822 return d->first;
823}
824
898{
899 Q_D(const QQuickRangeSlider);
900 return d->second;
901}
902
911{
912 Q_D(const QQuickRangeSlider);
913 return d->stepSize;
914}
915
917{
919 if (qFuzzyCompare(d->stepSize, step))
920 return;
921
922 d->stepSize = step;
924}
925
945{
946 Q_D(const QQuickRangeSlider);
947 return d->snapMode;
948}
949
951{
953 if (d->snapMode == mode)
954 return;
955
956 d->snapMode = mode;
958}
959
972{
973 Q_D(const QQuickRangeSlider);
974 return d->orientation;
975}
976
978{
980 if (d->orientation == orientation)
981 return;
982
985 else
987
988 d->orientation = orientation;
990}
991
1010void QQuickRangeSlider::setValues(qreal firstValue, qreal secondValue)
1011{
1012 Q_D(QQuickRangeSlider);
1013 // Restrict the values to be within to and from.
1014 const qreal smaller = qMin(d->to, d->from);
1015 const qreal larger = qMax(d->to, d->from);
1016 firstValue = qBound(smaller, firstValue, larger);
1017 secondValue = qBound(smaller, secondValue, larger);
1018
1019 if (d->from > d->to) {
1020 // If the from and to values are reversed, the secondValue
1021 // might be less than the first value, which is not allowed.
1022 if (secondValue > firstValue)
1023 secondValue = firstValue;
1024 } else {
1025 // Otherwise, clamp first to second if it's too large.
1026 if (firstValue > secondValue)
1027 firstValue = secondValue;
1028 }
1029
1030 // Then set both values. If they didn't change, no change signal will be emitted.
1032 if (firstValue != firstPrivate->value) {
1033 firstPrivate->value = firstValue;
1034 emit d->first->valueChanged();
1035 }
1036
1038 if (secondValue != secondPrivate->value) {
1039 secondPrivate->value = secondValue;
1040 emit d->second->valueChanged();
1041 }
1042
1043 // After we've set both values, then we can update the positions.
1044 // If we don't do this last, the positions may be incorrect.
1045 firstPrivate->updatePosition(true);
1046 secondPrivate->updatePosition();
1047}
1048
1061{
1062 Q_D(const QQuickRangeSlider);
1063 return d->live;
1064}
1065
1067{
1068 Q_D(QQuickRangeSlider);
1069 if (d->live == live)
1070 return;
1071
1072 d->live = live;
1073 emit liveChanged();
1074}
1075
1086{
1087 Q_D(const QQuickRangeSlider);
1088 return d->orientation == Qt::Horizontal;
1089}
1090
1101{
1102 Q_D(const QQuickRangeSlider);
1103 return d->orientation == Qt::Vertical;
1104}
1105
1107{
1108 Q_D(QQuickRangeSlider);
1110
1111 // The active focus ends up to RangeSlider when using forceActiveFocus()
1112 // or QML KeyNavigation. We must forward the focus to one of the handles,
1113 // because RangeSlider handles key events for the focused handle. If
1114 // neither handle has active focus, RangeSlider doesn't do anything.
1115 QQuickItem *handle = nextItemInFocusChain();
1116 // QQuickItem::nextItemInFocusChain() only works as desired with
1117 // Qt::TabFocusAllControls. otherwise pick the first handle
1118 if (!handle || handle == this)
1119 handle = d->first->handle();
1120 if (handle)
1121 handle->forceActiveFocus(event->reason());
1122}
1123
1125{
1126 Q_D(QQuickRangeSlider);
1128
1129 QQuickRangeSliderNode *focusNode = d->first->handle()->hasActiveFocus()
1130 ? d->first : (d->second->handle()->hasActiveFocus() ? d->second : nullptr);
1131 if (!focusNode)
1132 return;
1133
1134 const qreal oldValue = focusNode->value();
1135 if (d->orientation == Qt::Horizontal) {
1136 if (event->key() == Qt::Key_Left) {
1137 focusNode->setPressed(true);
1138 if (isMirrored())
1139 focusNode->increase();
1140 else
1141 focusNode->decrease();
1142 event->accept();
1143 } else if (event->key() == Qt::Key_Right) {
1144 focusNode->setPressed(true);
1145 if (isMirrored())
1146 focusNode->decrease();
1147 else
1148 focusNode->increase();
1149 event->accept();
1150 }
1151 } else {
1152 if (event->key() == Qt::Key_Up) {
1153 focusNode->setPressed(true);
1154 focusNode->increase();
1155 event->accept();
1156 } else if (event->key() == Qt::Key_Down) {
1157 focusNode->setPressed(true);
1158 focusNode->decrease();
1159 event->accept();
1160 }
1161 }
1162 if (!qFuzzyCompare(focusNode->value(), oldValue))
1163 emit focusNode->moved();
1164}
1165
1167{
1168 Q_D(QQuickRangeSlider);
1170 d->updateHover(event->position());
1171 event->ignore();
1172}
1173
1175{
1176 Q_D(QQuickRangeSlider);
1178 d->updateHover(event->position());
1179 event->ignore();
1180}
1181
1183{
1184 Q_D(QQuickRangeSlider);
1186 d->first->setHovered(false);
1187 d->second->setHovered(false);
1188 event->ignore();
1189}
1190
1192{
1193 Q_D(QQuickRangeSlider);
1195 d->first->setPressed(false);
1196 d->second->setPressed(false);
1197}
1198
1200{
1201 Q_D(QQuickRangeSlider);
1203 d->handleMove(event->position(), event->timestamp());
1204 setKeepMouseGrab(true);
1205}
1206
1207#if QT_CONFIG(quicktemplates2_multitouch)
1209{
1210 Q_D(QQuickRangeSlider);
1211 switch (event->type()) {
1213 for (const QTouchEvent::TouchPoint &point : event->points()) {
1214 if (!d->acceptTouch(point))
1215 continue;
1216
1217 switch (point.state()) {
1219 d->handlePress(point.position(), event->timestamp());
1220 break;
1222 if (!keepTouchGrab()) {
1223 if (d->orientation == Qt::Horizontal)
1224 setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - point.pressPosition().x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
1225 else
1226 setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().y() - point.pressPosition().y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
1227 }
1228 if (keepTouchGrab())
1229 d->handleMove(point.position(), event->timestamp());
1230 break;
1232 d->handleRelease(point.position(), event->timestamp());
1233 break;
1234 default:
1235 break;
1236 }
1237 }
1238 break;
1239
1240 default:
1242 break;
1243 }
1244}
1245#endif
1246
1248{
1249 Q_D(QQuickRangeSlider);
1251 emit d->first->visualPositionChanged();
1252 emit d->second->visualPositionChanged();
1253}
1254
1266
1268{
1269 Q_D(QQuickRangeSlider);
1272 firstPrivate->executeHandle(true);
1273 secondPrivate->executeHandle(true);
1274
1276
1277 if (firstPrivate->isPendingValue || secondPrivate->isPendingValue
1278 || !qFuzzyCompare(d->from, defaultFrom) || !qFuzzyCompare(d->to, defaultTo)) {
1279 // Properties were set while we were loading. To avoid clamping issues that occur when setting the
1280 // values of first and second overriding values set by the user, set them all at once at the end.
1281 // Another reason that we must set these values here is that the from and to values might have made the old range invalid.
1282 setValues(firstPrivate->isPendingValue ? firstPrivate->pendingValue : firstPrivate->value,
1283 secondPrivate->isPendingValue ? secondPrivate->pendingValue : secondPrivate->value);
1284
1285 firstPrivate->pendingValue = 0;
1286 firstPrivate->isPendingValue = false;
1287 secondPrivate->pendingValue = 0;
1288 secondPrivate->isPendingValue = false;
1289 } else {
1290 // If there was no pending data, we must still update the positions,
1291 // as first.setValue()/second.setValue() won't be called as part of default construction.
1292 // Don't need to ignore the second position when updating the first position here,
1293 // as our default values are guaranteed to be valid.
1294 firstPrivate->updatePosition();
1295 secondPrivate->updatePosition();
1296 }
1297}
1298
1331#if QT_CONFIG(accessibility)
1332QAccessible::Role QQuickRangeSlider::accessibleRole() const
1333{
1334 return QAccessible::Slider;
1335}
1336#endif
1337
1339
1340#include "moc_qquickrangeslider_p.cpp"
The QEventPoint class provides information about a point in a QPointerEvent.
Definition qeventpoint.h:20
QPointF pressPosition
the position at which this point was pressed.
Definition qeventpoint.h:36
int id
the ID number of this event point.
Definition qeventpoint.h:24
State state
the current state of the event point.
Definition qeventpoint.h:26
QPointF position
the position of this point.
Definition qeventpoint.h:35
@ TouchUpdate
Definition qcoreevent.h:242
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\inmodule QtGui
Definition qevent.h:246
The QKeyEvent class describes a key event.
Definition qevent.h:424
static constexpr Policy Preferred
static constexpr Policy Fixed
\inmodule QtGui
Definition qevent.h:196
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore\reentrant
Definition qpoint.h:217
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:343
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:348
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static void setContextForObject(QObject *, QQmlContext *)
Sets the QQmlContext for the object to context.
void itemImplicitWidthChanged(QQuickItem *item) override
virtual bool handlePress(const QPointF &point, ulong timestamp)
static void hideOldItem(QQuickItem *item)
virtual void handleUngrab()
virtual bool handleRelease(const QPointF &point, ulong timestamp)
static void warnIfCustomizationNotSupported(QObject *control, QQuickItem *item, const QString &propertyName)
void itemDestroyed(QQuickItem *item) override
virtual bool handleMove(const QPointF &point, ulong timestamp)
static QQuickControlPrivate * get(QQuickControl *control)
void itemImplicitHeightChanged(QQuickItem *item) override
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void classBegin() override
Invoked after class creation, but before any properties have been set.
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
bool isMirrored() const
\qmlproperty bool QtQuick.Controls::Control::mirrored \readonly
virtual void mirrorChange()
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
virtual void hoverEnterEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void setKeepTouchGrab(bool)
Sets whether the touch points grabbed by this item should remain exclusively with this item.
void setFlag(Flag flag, bool enabled=true)
Enables the specified flag for this item if enabled is true; if enabled is false, the flag is disable...
virtual void keyPressEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key press events for an item.
void setParentItem(QQuickItem *parent)
virtual void hoverMoveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void setAcceptTouchEvents(bool accept)
If enabled is true, this sets the item to accept touch events; otherwise, touch events are not accept...
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
bool keepTouchGrab() const
Returns whether the touch points grabbed by this item should exclusively remain with this item.
qreal width
This property holds the width of this item.
Definition qquickitem.h:75
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
QPointF position() const
bool isEnabled() const
void setKeepMouseGrab(bool)
Sets whether the mouse input should remain exclusively with this item.
virtual void touchEvent(QTouchEvent *event)
This event handler can be reimplemented in a subclass to receive touch events for an item.
qreal height
This property holds the height of this item.
Definition qquickitem.h:76
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
void setFocusPolicy(Qt::FocusPolicy policy)
Sets the focus policy of this item to policy.
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
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)
QQuickDeferredPointer< QQuickItem > handle
static QQuickRangeSliderNodePrivate * get(QQuickRangeSliderNode *node)
QQuickRangeSliderNodePrivate(qreal value, QQuickRangeSlider *slider)
void updatePosition(bool ignoreOtherPosition=false)
QQuickRangeSliderNode(qreal value, QQuickRangeSlider *slider)
void implicitHandleHeightChanged()
void setHandle(QQuickItem *handle)
void setPressed(bool pressed)
void implicitHandleWidthChanged()
void setHovered(bool hovered)
QQuickRangeSlider::SnapMode snapMode
QQuickRangeSliderNode * second
bool handleMove(const QPointF &point, ulong timestamp) override
QQuickRangeSliderNode * first
void itemDestroyed(QQuickItem *item) override
bool handleRelease(const QPointF &point, ulong timestamp) override
QQuickRangeSliderNode * pressedNode(int touchId=-1) const
void itemImplicitHeightChanged(QQuickItem *item) override
bool handlePress(const QPointF &point, ulong timestamp) override
void updateHover(const QPointF &pos)
void itemImplicitWidthChanged(QQuickItem *item) override
void classBegin() override
Invoked after class creation, but before any properties have been set.
void mousePressEvent(QMouseEvent *event) override
This event handler can be reimplemented in a subclass to receive mouse press events for an item.
void hoverEnterEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void keyReleaseEvent(QKeyEvent *event) override
This event handler can be reimplemented in a subclass to receive key release events for an item.
void mirrorChange() override
void hoverMoveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void setStepSize(qreal step)
Q_INVOKABLE void setValues(qreal firstValue, qreal secondValue)
\qmlmethod void QtQuick.Controls::RangeSlider::setValues(real firstValue, real secondValue)
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-in events for an item.
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
QQuickRangeSliderNode * second
QQuickRangeSlider(QQuickItem *parent=nullptr)
void setSnapMode(SnapMode mode)
Qt::Orientation orientation
void setTouchDragThreshold(qreal touchDragThreshold)
friend class QQuickRangeSliderNode
void setOrientation(Qt::Orientation orientation)
QQuickRangeSliderNode * first
void keyPressEvent(QKeyEvent *event) override
This event handler can be reimplemented in a subclass to receive key press events for an item.
void setFrom(qreal from)
void hoverLeaveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void orientationChanged()
static bool dragOverThreshold(qreal d, Qt::Axis axis, const QEventPoint *tp, int startDragThreshold=-1)
The QTouchEvent class contains parameters that describe a touch event.
Definition qevent.h:917
Combined button and popup list for selecting options.
@ LeftButton
Definition qnamespace.h:58
@ ClickFocus
Definition qnamespace.h:109
@ TabFocus
Definition qnamespace.h:108
@ StrongFocus
Definition qnamespace.h:110
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ ArrowCursor
@ Key_Right
Definition qnamespace.h:679
@ Key_Left
Definition qnamespace.h:677
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
@ MouseFocusReason
@ XAxis
@ YAxis
static void * context
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
n void setPosition(void) \n\
GLuint64 GLenum void * handle
GLenum mode
GLsizei range
GLenum GLuint GLintptr offset
GLint first
struct _cl_event * event
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLfloat * val
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:75
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
void quickCancelDeferred(QObject *object, const QString &property)
void quickCompleteDeferred(QObject *object, const QString &property, QQuickDeferredPointer< T > &delegate)
void quickBeginDeferred(QObject *object, const QString &property, QQuickDeferredPointer< T > &delegate)
static const qreal defaultTo
static const qreal defaultFrom
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)
#define QStringLiteral(str)
#define emit
static QString handleName()
unsigned long ulong
Definition qtypes.h:35
double qreal
Definition qtypes.h:187
item setCursor(Qt::IBeamCursor)
[1]
QGraphicsItem * item