Qt 6.x
The Qt SDK
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:
67 : value(value),
69 {
70 }
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;
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
121{
124}
125
127{
129 if (handle.wasExecuted())
130 return;
131
132 if (!handle || complete)
134 if (complete)
136}
137
139{
140 return node->d_func();
141}
142
144 : QObject(*(new QQuickRangeSliderNodePrivate(value, slider)), slider)
145{
146}
147
149{
150}
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
228 if (!d->handle.isExecuting())
229 d->cancelHandle();
230
231 const qreal oldImplicitHandleWidth = implicitHandleWidth();
232 const qreal oldImplicitHandleHeight = implicitHandleHeight();
233
236 d->handle = handle;
237
238 if (handle) {
239 if (!handle->parentItem())
240 handle->setParentItem(d->slider);
241
242 QQuickItem *firstHandle = QQuickRangeSliderNodePrivate::get(d->slider->first())->handle;
243 QQuickItem *secondHandle = QQuickRangeSliderNodePrivate::get(d->slider->second())->handle;
244 if (firstHandle && secondHandle) {
245 // The order of property assignments in QML is undefined,
246 // but we need the first handle to be before the second due
247 // to focus order constraints, so check for that here.
248 const QList<QQuickItem *> childItems = d->slider->childItems();
249 const int firstIndex = childItems.indexOf(firstHandle);
250 const int secondIndex = childItems.indexOf(secondHandle);
251 if (firstIndex != -1 && secondIndex != -1 && firstIndex > secondIndex) {
252 firstHandle->stackBefore(secondHandle);
253 // Ensure we have some way of knowing which handle is above
254 // the other when it comes to mouse presses, and also that
255 // they are rendered in the correct order.
256 secondHandle->setZ(secondHandle->z() + 1);
257 }
258 }
259
260 handle->setActiveFocusOnTab(true);
262 }
263
264 if (!qFuzzyCompare(oldImplicitHandleWidth, implicitHandleWidth()))
266 if (!qFuzzyCompare(oldImplicitHandleHeight, implicitHandleHeight()))
268 if (!d->handle.isExecuting())
270}
271
273{
274 Q_D(const QQuickRangeSliderNode);
275 return d->pressed;
276}
277
279{
281 if (d->pressed == pressed)
282 return;
283
284 d->pressed = pressed;
285 d->slider->setAccessibleProperty("pressed", pressed || d->slider->second()->isPressed());
287}
288
290{
291 Q_D(const QQuickRangeSliderNode);
292 return d->hovered;
293}
294
296{
298 if (d->hovered == hovered)
299 return;
300
301 d->hovered = hovered;
302 emit hoveredChanged();
303}
304
306{
307 Q_D(const QQuickRangeSliderNode);
308 if (!d->handle)
309 return 0;
310 return d->handle->implicitWidth();
311}
312
314{
315 Q_D(const QQuickRangeSliderNode);
316 if (!d->handle)
317 return 0;
318 return d->handle->implicitHeight();
319}
320
322{
324 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
325 setValue(d->value + step);
326}
327
329{
331 qreal step = qFuzzyIsNull(d->slider->stepSize()) ? 0.1 : d->slider->stepSize();
332 setValue(d->value - step);
333}
334
335static const qreal defaultFrom = 0.0;
336static const qreal defaultTo = 1.0;
337
339{
340 Q_DECLARE_PUBLIC(QQuickRangeSlider)
341
342public:
344
345#if QT_CONFIG(quicktemplates2_multitouch)
346 bool acceptTouch(const QTouchEvent::TouchPoint &point) override;
347#endif
348 bool handlePress(const QPointF &point, ulong timestamp) override;
349 bool handleMove(const QPointF &point, ulong timestamp) override;
350 bool handleRelease(const QPointF &point, ulong timestamp) override;
351 void handleUngrab() override;
352
353 void updateHover(const QPointF &pos);
354
357
358 bool live = true;
368};
369
371{
372 return slider->from() + (slider->to() - slider->from()) * position;
373}
374
376{
377 const qreal range = slider->to() - slider->from();
378 if (qFuzzyIsNull(range))
379 return position;
380
381 const qreal effectiveStep = slider->stepSize() / range;
382 if (qFuzzyIsNull(effectiveStep))
383 return position;
384
385 return qRound(position / effectiveStep) * effectiveStep;
386}
387
388static qreal positionAt(const QQuickRangeSlider *slider, QQuickItem *handle, const QPointF &point)
389{
390 if (slider->orientation() == Qt::Horizontal) {
391 const qreal hw = handle ? handle->width() : 0;
392 const qreal offset = hw / 2;
393 const qreal extent = slider->availableWidth() - hw;
394 if (!qFuzzyIsNull(extent)) {
395 if (slider->isMirrored())
396 return (slider->width() - point.x() - slider->rightPadding() - offset) / extent;
397 return (point.x() - slider->leftPadding() - offset) / extent;
398 }
399 } else {
400 const qreal hh = handle ? handle->height() : 0;
401 const qreal offset = hh / 2;
402 const qreal extent = slider->availableHeight() - hh;
403 if (!qFuzzyIsNull(extent))
404 return (slider->height() - point.y() - slider->bottomPadding() - offset) / extent;
405 }
406 return 0;
407}
408
410{
411 if (touchId == -1)
412 return first->isPressed() ? first : (second->isPressed() ? second : nullptr);
414 return first;
416 return second;
417 return nullptr;
418}
419
420#if QT_CONFIG(quicktemplates2_multitouch)
421bool QQuickRangeSliderPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
422{
425
426 if (((firstId == -1 || secondId == -1) && point.state() == QEventPoint::Pressed) || point.id() == firstId || point.id() == secondId) {
427 touchId = point.id();
428 return true;
429 }
430
431 return false;
432}
433#endif
434
436{
438 QQuickControlPrivate::handlePress(point, timestamp);
439 pressPoint = point;
440
441 QQuickItem *firstHandle = first->handle();
442 QQuickItem *secondHandle = second->handle();
443 const bool firstHit = firstHandle && !first->isPressed() && firstHandle->contains(q->mapToItem(firstHandle, point));
444 const bool secondHit = secondHandle && !second->isPressed() && secondHandle->contains(q->mapToItem(secondHandle, point));
445 QQuickRangeSliderNode *hitNode = nullptr;
446 QQuickRangeSliderNode *otherNode = nullptr;
447
448 if (firstHit && secondHit) {
449 // choose highest
450 hitNode = firstHandle->z() > secondHandle->z() ? first : second;
451 otherNode = firstHandle->z() > secondHandle->z() ? second : first;
452 } else if (firstHit) {
453 hitNode = first;
454 otherNode = second;
455 } else if (secondHit) {
456 hitNode = second;
457 otherNode = first;
458 } else {
459 // find the nearest
460 const qreal firstPos = positionAt(q, firstHandle, point);
461 const qreal secondPos = positionAt(q, secondHandle, point);
462 const qreal firstDistance = qAbs(firstPos - first->position());
463 const qreal secondDistance = qAbs(secondPos - second->position());
464
465 if (qFuzzyCompare(firstDistance, secondDistance)) {
466 // same distance => choose the one that can be moved towards the press position
467 const bool inverted = from > to;
468 if ((!inverted && firstPos < first->position()) || (inverted && firstPos > first->position())) {
469 hitNode = first;
470 otherNode = second;
471 } else {
472 hitNode = second;
473 otherNode = first;
474 }
475 } else if (firstDistance < secondDistance) {
476 hitNode = first;
477 otherNode = second;
478 } else {
479 hitNode = second;
480 otherNode = first;
481 }
482 }
483
484 if (hitNode) {
485 hitNode->setPressed(true);
486 if (QQuickItem *handle = hitNode->handle())
487 handle->setZ(1);
489 }
490 if (otherNode) {
491 if (QQuickItem *handle = otherNode->handle())
492 handle->setZ(0);
493 }
494 return true;
495}
496
498{
500 QQuickControlPrivate::handleMove(point, timestamp);
502 if (pressedNode) {
503 const qreal oldPos = pressedNode->position();
504 qreal pos = positionAt(q, pressedNode->handle(), point);
506 pos = snapPosition(q, pos);
507 if (live)
509 else
511
512 if (!qFuzzyCompare(pressedNode->position(), oldPos))
514 }
515 return true;
516}
517
519{
521 QQuickControlPrivate::handleRelease(point, timestamp);
523
525 if (!pressedNode)
526 return true;
528
529 const qreal oldPos = pressedNode->position();
530 qreal pos = positionAt(q, pressedNode->handle(), point);
532 pos = snapPosition(q, pos);
533 qreal val = valueAt(q, pos);
537 pressedNodePrivate->setPosition(pos);
538 q->setKeepMouseGrab(false);
539 q->setKeepTouchGrab(false);
540
541 if (!qFuzzyCompare(pressedNode->position(), oldPos))
543
544 pressedNode->setPressed(false);
545 pressedNodePrivate->touchId = -1;
546 return true;
547}
548
550{
553 first->setPressed(false);
554 second->setPressed(false);
557}
558
560{
562 QQuickItem *firstHandle = first->handle();
563 QQuickItem *secondHandle = second->handle();
564 bool firstHandleHovered = firstHandle && firstHandle->isEnabled()
565 && firstHandle->contains(q->mapToItem(firstHandle, pos));
566 bool secondHandleHovered = secondHandle && secondHandle->isEnabled()
567 && secondHandle->contains(q->mapToItem(secondHandle, pos));
568
569 if (firstHandleHovered && secondHandleHovered) {
570 // Only hover the handle with the higher Z value.
571 const bool firstHandleHasHigherZ = firstHandle->z() > secondHandle->z();
572 firstHandleHovered = firstHandleHasHigherZ;
573 secondHandleHovered = !firstHandleHasHigherZ;
574 }
575 first->setHovered(firstHandleHovered);
576 second->setHovered(secondHandleHovered);
577}
578
580{
582 if (item == first->handle())
583 emit first->implicitHandleWidthChanged();
584 else if (item == second->handle())
586}
587
589{
591 if (item == first->handle())
592 emit first->implicitHandleHeightChanged();
593 else if (item == second->handle())
595}
596
599{
601 d->first = new QQuickRangeSliderNode(0.0, this);
602 d->second = new QQuickRangeSliderNode(1.0, this);
603
606#if QT_CONFIG(quicktemplates2_multitouch)
608#endif
609#if QT_CONFIG(cursor)
611#endif
612}
613
615{
617 d->removeImplicitSizeListener(d->first->handle());
618 d->removeImplicitSizeListener(d->second->handle());
619}
620
629{
630 Q_D(const QQuickRangeSlider);
631 return d->from;
632}
633
635{
637 if (qFuzzyCompare(d->from, from))
638 return;
639
640 d->from = from;
642
643 if (isComponentComplete()) {
644 d->first->setValue(d->first->value());
645 d->second->setValue(d->second->value());
646 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
647 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
648 firstPrivate->updatePosition(true);
649 secondPrivate->updatePosition();
650 }
651}
652
661{
662 Q_D(const QQuickRangeSlider);
663 return d->to;
664}
665
667{
669 if (qFuzzyCompare(d->to, to))
670 return;
671
672 d->to = to;
673 emit toChanged();
674
675 if (isComponentComplete()) {
676 d->first->setValue(d->first->value());
677 d->second->setValue(d->second->value());
678 auto *firstPrivate = QQuickRangeSliderNodePrivate::get(d->first);
679 auto *secondPrivate = QQuickRangeSliderNodePrivate::get(d->second);
680 firstPrivate->updatePosition(true);
681 secondPrivate->updatePosition();
682 }
683}
684
697{
698 Q_D(const QQuickRangeSlider);
699 return d->touchDragThreshold;
700}
701
703{
705 if (d->touchDragThreshold == touchDragThreshold)
706 return;
707
708 d->touchDragThreshold = touchDragThreshold;
709 emit touchDragThresholdChanged();
710}
711
713{
715}
716
725qreal QQuickRangeSlider::valueAt(qreal position) const
726{
727 Q_D(const QQuickRangeSlider);
728 const qreal value = (d->to - d->from) * position;
729 if (qFuzzyIsNull(d->stepSize))
730 return d->from + value;
731 return d->from + qRound(value / d->stepSize) * d->stepSize;
732}
733
796{
797 Q_D(const QQuickRangeSlider);
798 return d->first;
799}
800
874{
875 Q_D(const QQuickRangeSlider);
876 return d->second;
877}
878
887{
888 Q_D(const QQuickRangeSlider);
889 return d->stepSize;
890}
891
893{
895 if (qFuzzyCompare(d->stepSize, step))
896 return;
897
898 d->stepSize = step;
900}
901
921{
922 Q_D(const QQuickRangeSlider);
923 return d->snapMode;
924}
925
927{
929 if (d->snapMode == mode)
930 return;
931
932 d->snapMode = mode;
934}
935
948{
949 Q_D(const QQuickRangeSlider);
950 return d->orientation;
951}
952
954{
956 if (d->orientation == orientation)
957 return;
958
959 d->orientation = orientation;
961}
962
981void QQuickRangeSlider::setValues(qreal firstValue, qreal secondValue)
982{
984 // Restrict the values to be within to and from.
985 const qreal smaller = qMin(d->to, d->from);
986 const qreal larger = qMax(d->to, d->from);
987 firstValue = qBound(smaller, firstValue, larger);
988 secondValue = qBound(smaller, secondValue, larger);
989
990 if (d->from > d->to) {
991 // If the from and to values are reversed, the secondValue
992 // might be less than the first value, which is not allowed.
993 if (secondValue > firstValue)
994 secondValue = firstValue;
995 } else {
996 // Otherwise, clamp first to second if it's too large.
997 if (firstValue > secondValue)
998 firstValue = secondValue;
999 }
1000
1001 // Then set both values. If they didn't change, no change signal will be emitted.
1003 if (firstValue != firstPrivate->value) {
1004 firstPrivate->value = firstValue;
1005 emit d->first->valueChanged();
1006 }
1007
1009 if (secondValue != secondPrivate->value) {
1010 secondPrivate->value = secondValue;
1011 emit d->second->valueChanged();
1012 }
1013
1014 // After we've set both values, then we can update the positions.
1015 // If we don't do this last, the positions may be incorrect.
1016 firstPrivate->updatePosition(true);
1017 secondPrivate->updatePosition();
1018}
1019
1032{
1033 Q_D(const QQuickRangeSlider);
1034 return d->live;
1035}
1036
1038{
1039 Q_D(QQuickRangeSlider);
1040 if (d->live == live)
1041 return;
1042
1043 d->live = live;
1044 emit liveChanged();
1045}
1046
1057{
1058 Q_D(const QQuickRangeSlider);
1059 return d->orientation == Qt::Horizontal;
1060}
1061
1072{
1073 Q_D(const QQuickRangeSlider);
1074 return d->orientation == Qt::Vertical;
1075}
1076
1078{
1079 Q_D(QQuickRangeSlider);
1081
1082 // The active focus ends up to RangeSlider when using forceActiveFocus()
1083 // or QML KeyNavigation. We must forward the focus to one of the handles,
1084 // because RangeSlider handles key events for the focused handle. If
1085 // neither handle has active focus, RangeSlider doesn't do anything.
1086 QQuickItem *handle = nextItemInFocusChain();
1087 // QQuickItem::nextItemInFocusChain() only works as desired with
1088 // Qt::TabFocusAllControls. otherwise pick the first handle
1089 if (!handle || handle == this)
1090 handle = d->first->handle();
1091 if (handle)
1092 handle->forceActiveFocus(event->reason());
1093}
1094
1096{
1097 Q_D(QQuickRangeSlider);
1099
1100 QQuickRangeSliderNode *focusNode = d->first->handle()->hasActiveFocus()
1101 ? d->first : (d->second->handle()->hasActiveFocus() ? d->second : nullptr);
1102 if (!focusNode)
1103 return;
1104
1105 const qreal oldValue = focusNode->value();
1106 if (d->orientation == Qt::Horizontal) {
1107 if (event->key() == Qt::Key_Left) {
1108 focusNode->setPressed(true);
1109 if (isMirrored())
1110 focusNode->increase();
1111 else
1112 focusNode->decrease();
1113 event->accept();
1114 } else if (event->key() == Qt::Key_Right) {
1115 focusNode->setPressed(true);
1116 if (isMirrored())
1117 focusNode->decrease();
1118 else
1119 focusNode->increase();
1120 event->accept();
1121 }
1122 } else {
1123 if (event->key() == Qt::Key_Up) {
1124 focusNode->setPressed(true);
1125 focusNode->increase();
1126 event->accept();
1127 } else if (event->key() == Qt::Key_Down) {
1128 focusNode->setPressed(true);
1129 focusNode->decrease();
1130 event->accept();
1131 }
1132 }
1133 if (!qFuzzyCompare(focusNode->value(), oldValue))
1134 emit focusNode->moved();
1135}
1136
1138{
1139 Q_D(QQuickRangeSlider);
1141 d->updateHover(event->position());
1142 event->ignore();
1143}
1144
1146{
1147 Q_D(QQuickRangeSlider);
1149 d->updateHover(event->position());
1150 event->ignore();
1151}
1152
1154{
1155 Q_D(QQuickRangeSlider);
1157 d->first->setHovered(false);
1158 d->second->setHovered(false);
1159 event->ignore();
1160}
1161
1163{
1164 Q_D(QQuickRangeSlider);
1166 d->first->setPressed(false);
1167 d->second->setPressed(false);
1168}
1169
1171{
1172 Q_D(QQuickRangeSlider);
1174 d->handleMove(event->position(), event->timestamp());
1175 setKeepMouseGrab(true);
1176}
1177
1178#if QT_CONFIG(quicktemplates2_multitouch)
1180{
1181 Q_D(QQuickRangeSlider);
1182 switch (event->type()) {
1184 for (const QTouchEvent::TouchPoint &point : event->points()) {
1185 if (!d->acceptTouch(point))
1186 continue;
1187
1188 switch (point.state()) {
1190 d->handlePress(point.position(), event->timestamp());
1191 break;
1193 if (!keepTouchGrab()) {
1194 if (d->orientation == Qt::Horizontal)
1195 setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().x() - point.pressPosition().x(), Qt::XAxis, &point, qRound(d->touchDragThreshold)));
1196 else
1197 setKeepTouchGrab(QQuickWindowPrivate::dragOverThreshold(point.position().y() - point.pressPosition().y(), Qt::YAxis, &point, qRound(d->touchDragThreshold)));
1198 }
1199 if (keepTouchGrab())
1200 d->handleMove(point.position(), event->timestamp());
1201 break;
1203 d->handleRelease(point.position(), event->timestamp());
1204 break;
1205 default:
1206 break;
1207 }
1208 }
1209 break;
1210
1211 default:
1213 break;
1214 }
1215}
1216#endif
1217
1219{
1220 Q_D(QQuickRangeSlider);
1222 emit d->first->visualPositionChanged();
1223 emit d->second->visualPositionChanged();
1224}
1225
1227{
1228 Q_D(QQuickRangeSlider);
1230
1232 if (context) {
1235 }
1236}
1237
1239{
1240 Q_D(QQuickRangeSlider);
1243 firstPrivate->executeHandle(true);
1244 secondPrivate->executeHandle(true);
1245
1247
1248 if (firstPrivate->isPendingValue || secondPrivate->isPendingValue
1249 || !qFuzzyCompare(d->from, defaultFrom) || !qFuzzyCompare(d->to, defaultTo)) {
1250 // Properties were set while we were loading. To avoid clamping issues that occur when setting the
1251 // values of first and second overriding values set by the user, set them all at once at the end.
1252 // Another reason that we must set these values here is that the from and to values might have made the old range invalid.
1253 setValues(firstPrivate->isPendingValue ? firstPrivate->pendingValue : firstPrivate->value,
1254 secondPrivate->isPendingValue ? secondPrivate->pendingValue : secondPrivate->value);
1255
1256 firstPrivate->pendingValue = 0;
1257 firstPrivate->isPendingValue = false;
1258 secondPrivate->pendingValue = 0;
1259 secondPrivate->isPendingValue = false;
1260 } else {
1261 // If there was no pending data, we must still update the positions,
1262 // as first.setValue()/second.setValue() won't be called as part of default construction.
1263 // Don't need to ignore the second position when updating the first position here,
1264 // as our default values are guaranteed to be valid.
1265 firstPrivate->updatePosition();
1266 secondPrivate->updatePosition();
1267 }
1268}
1269
1302#if QT_CONFIG(accessibility)
1303QAccessible::Role QQuickRangeSlider::accessibleRole() const
1304{
1305 return QAccessible::Slider;
1306}
1307#endif
1308
1310
1311#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:37
int id
the ID number of this event point.
Definition qeventpoint.h:25
State state
the current state of the event point.
Definition qeventpoint.h:27
QPointF position
the position of this point.
Definition qeventpoint.h:36
@ TouchUpdate
Definition qcoreevent.h:242
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
\inmodule QtGui
Definition qevent.h:245
The QKeyEvent class describes a key event.
Definition qevent.h:423
Definition qlist.h:74
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore\reentrant
Definition qpoint.h:214
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:333
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:338
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)
void removeImplicitSizeListener(QQuickItem *item, ChangeTypes changes=ImplicitSizeChanges)
void addImplicitSizeListener(QQuickItem *item, ChangeTypes changes=ImplicitSizeChanges)
static void hideOldItem(QQuickItem *item)
virtual void handleUngrab()
virtual bool handleRelease(const QPointF &point, ulong timestamp)
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:64
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)
qreal z
\qmlproperty real QtQuick::Item::z
Definition qquickitem.h:75
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:76
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:77
void setZ(qreal)
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void stackBefore(const QQuickItem *)
Moves the specified sibling item to the index before this item within the list of children.
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
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:916
Combined button and popup list for selecting options.
@ LeftButton
Definition qnamespace.h:57
Orientation
Definition qnamespace.h:97
@ Horizontal
Definition qnamespace.h:98
@ Vertical
Definition qnamespace.h:99
@ ArrowCursor
@ Key_Right
Definition qnamespace.h:674
@ Key_Left
Definition qnamespace.h:672
@ Key_Up
Definition qnamespace.h:673
@ Key_Down
Definition qnamespace.h:675
@ XAxis
@ YAxis
static void * context
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:287
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:303
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
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:71
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 emit
static QString handleName()
unsigned long ulong
Definition qtypes.h:30
double qreal
Definition qtypes.h:92
item setCursor(Qt::IBeamCursor)
[1]
QGraphicsItem * item
qsizetype indexOf(const AT &t, qsizetype from=0) const noexcept
Definition qlist.h:955
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent