Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickspinbox.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
4#include "qquickspinbox_p.h"
5#include "qquickcontrol_p_p.h"
8
9#include <QtGui/qguiapplication.h>
10#include <QtGui/qstylehints.h>
11
12#include <QtQml/qqmlinfo.h>
13#if QT_CONFIG(qml_locale)
14#include <QtQml/private/qqmllocale_p.h>
15#endif
16#include <QtQml/private/qqmlengine_p.h>
17#include <QtQuick/private/qquicktextinput_p.h>
18
20
21// copied from qabstractbutton.cpp
22static const int AUTO_REPEAT_DELAY = 300;
23static const int AUTO_REPEAT_INTERVAL = 100;
24
29
80{
81 Q_DECLARE_PUBLIC(QQuickSpinBox)
82
83public:
84 int boundValue(int value, bool wrap) const;
85 void updateValue();
86 bool setValue(int value, bool wrap, bool modified);
87 bool stepBy(int steps, bool modified);
88 void increase(bool modified);
89 void decrease(bool modified);
90
91 int effectiveStepSize() const;
92
93 void updateDisplayText();
96
97 bool upEnabled() const;
98 void updateUpEnabled();
99 bool downEnabled() const;
100 void updateDownEnabled();
101 void updateHover(const QPointF &pos);
102
103 void startRepeatDelay();
104 void startPressRepeat();
105 void stopPressRepeat();
106
107 bool handlePress(const QPointF &point, ulong timestamp) override;
108 bool handleMove(const QPointF &point, ulong timestamp) override;
109 bool handleRelease(const QPointF &point, ulong timestamp) override;
110 void handleUngrab() override;
111
114
116 int evaluateValueFromText(const QString &text) const;
117
119
120 bool editable = false;
121 bool live = false;
122 bool wrap = false;
123 int from = 0;
124 int to = 99;
125 int value = 0;
126 int stepSize = 1;
127 int delayTimer = 0;
128 int repeatTimer = 0;
132#if QT_CONFIG(validator)
133 QValidator *validator = nullptr;
134#endif
137 Qt::InputMethodHints inputMethodHints = Qt::ImhDigitsOnly;
138};
139
141{
142 bool inverted = from > to;
143 if (!wrap)
144 return inverted ? qBound(to, value, from) : qBound(from, value, to);
145
146 int f = inverted ? to : from;
147 int t = inverted ? from : to;
148 if (value < f)
149 value = t;
150 else if (value > t)
151 value = f;
152
153 return value;
154}
155
157{
158 if (contentItem) {
160 if (text.isValid()) {
161 setValue(evaluateValueFromText(text.toString()), /* allowWrap = */ false, /* modified = */ true);
162 }
163 }
164}
165
166// modified indicates if the value was modified by the user and not programatically
167// this is then passed on to updateDisplayText to indicate that the user has modified
168// the value so it may need to trigger an update of the contentItem's text too
169
170bool QQuickSpinBoxPrivate::setValue(int newValue, bool allowWrap, bool modified)
171{
172 Q_Q(QQuickSpinBox);
173 int correctedValue = newValue;
174 if (q->isComponentComplete())
175 correctedValue = boundValue(newValue, allowWrap);
176
177 if (!modified && newValue == correctedValue && newValue == value)
178 return false;
179
180 const bool emitSignals = (value != correctedValue);
181 value = correctedValue;
182
186
187 // Only emit the signals if the corrected value is not the same as the
188 // original value to avoid unnecessary updates
189 if (emitSignals) {
190 emit q->valueChanged();
191 if (modified)
192 emit q->valueModified();
193 }
194 return true;
195}
196
197bool QQuickSpinBoxPrivate::stepBy(int steps, bool modified)
198{
199 return setValue(value + steps, wrap, modified);
200}
201
203{
204 setValue(value + effectiveStepSize(), wrap, modified);
205}
206
208{
209 setValue(value - effectiveStepSize(), wrap, modified);
210}
211
213{
214 return from > to ? -1 * stepSize : stepSize;
215}
216
218{
220}
221
223{
224 Q_Q(QQuickSpinBox);
225
226 if (displayText == text)
227 return;
228
230 emit q->displayTextChanged();
231}
232
234{
235 Q_Q(QQuickSpinBox);
236
237 QQuickTextInput *inputTextItem = qobject_cast<QQuickTextInput *>(q->contentItem());
238 if (!inputTextItem)
239 return;
240 QString text = inputTextItem->text();
241 validator->fixup(text);
242
243 if (live) {
244 const int enteredVal = evaluateValueFromText(text);
245 const int correctedValue = boundValue(enteredVal, false);
246 if (correctedValue == enteredVal && correctedValue != value) {
247 // If live is true and the text is valid change the value
248 // setValue will set the displayText for us.
249 q->setValue(correctedValue);
250 return;
251 }
252 }
253 // If live is false or the value is not valid, just set the displayText
255}
256
258{
259 const QQuickItem *upIndicator = up->indicator();
260 return upIndicator && upIndicator->isEnabled();
261}
262
264{
265 QQuickItem *upIndicator = up->indicator();
266 if (!upIndicator)
267 return;
268
269 upIndicator->setEnabled(wrap || (from < to ? value < to : value > to));
270}
271
273{
274 const QQuickItem *downIndicator = down->indicator();
275 return downIndicator && downIndicator->isEnabled();
276}
277
279{
280 QQuickItem *downIndicator = down->indicator();
281 if (!downIndicator)
282 return;
283
284 downIndicator->setEnabled(wrap || (from < to ? value > from : value < from));
285}
286
288{
289 Q_Q(QQuickSpinBox);
290 QQuickItem *ui = up->indicator();
291 QQuickItem *di = down->indicator();
292 up->setHovered(ui && ui->isEnabled() && ui->contains(q->mapToItem(ui, pos)));
293 down->setHovered(di && di->isEnabled() && di->contains(q->mapToItem(di, pos)));
294}
295
297{
298 Q_Q(QQuickSpinBox);
300 delayTimer = q->startTimer(AUTO_REPEAT_DELAY);
301}
302
304{
305 Q_Q(QQuickSpinBox);
307 repeatTimer = q->startTimer(AUTO_REPEAT_INTERVAL);
308}
309
311{
312 Q_Q(QQuickSpinBox);
313 if (delayTimer > 0) {
314 q->killTimer(delayTimer);
315 delayTimer = 0;
316 }
317 if (repeatTimer > 0) {
318 q->killTimer(repeatTimer);
319 repeatTimer = 0;
320 }
321}
322
324{
325 Q_Q(QQuickSpinBox);
326 QQuickControlPrivate::handlePress(point, timestamp);
327 QQuickItem *ui = up->indicator();
328 QQuickItem *di = down->indicator();
329 up->setPressed(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(q, point)));
330 down->setPressed(di && di->isEnabled() && di->contains(di->mapFromItem(q, point)));
331
332 bool pressed = up->isPressed() || down->isPressed();
333 q->setAccessibleProperty("pressed", pressed);
334 if (pressed)
336 return true;
337}
338
339bool QQuickSpinBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
340{
341 Q_Q(QQuickSpinBox);
342 QQuickControlPrivate::handleMove(point, timestamp);
343 QQuickItem *ui = up->indicator();
344 QQuickItem *di = down->indicator();
345 up->setHovered(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(q, point)));
347 down->setHovered(di && di->isEnabled() && di->contains(di->mapFromItem(q, point)));
349
350 bool pressed = up->isPressed() || down->isPressed();
351 q->setAccessibleProperty("pressed", pressed);
352 if (!pressed)
354 return true;
355}
356
358{
359 Q_Q(QQuickSpinBox);
360 QQuickControlPrivate::handleRelease(point, timestamp);
361 QQuickItem *ui = up->indicator();
362 QQuickItem *di = down->indicator();
363
364 int oldValue = value;
365 if (up->isPressed()) {
366 if (repeatTimer <= 0 && ui && ui->contains(ui->mapFromItem(q, point)))
367 q->increase();
368 // Retain pressed state until after increasing is done in case user code binds stepSize
369 // to up/down.pressed.
370 up->setPressed(false);
371 } else if (down->isPressed()) {
372 if (repeatTimer <= 0 && di && di->contains(di->mapFromItem(q, point)))
373 q->decrease();
374 down->setPressed(false);
375 }
376 if (value != oldValue)
377 emit q->valueModified();
378
379 q->setAccessibleProperty("pressed", false);
381 return true;
382}
383
385{
386 Q_Q(QQuickSpinBox);
388 up->setPressed(false);
389 down->setPressed(false);
390
391 q->setAccessibleProperty("pressed", false);
393}
394
396{
398 if (item == up->indicator())
399 emit up->implicitIndicatorWidthChanged();
400 else if (item == down->indicator())
401 emit down->implicitIndicatorWidthChanged();
402}
403
405{
407 if (item == up->indicator())
408 emit up->implicitIndicatorHeightChanged();
409 else if (item == down->indicator())
410 emit down->implicitIndicatorHeightChanged();
411}
412
413
415{
416 Q_Q(const QQuickSpinBox);
417
421 QJSValue loc;
422#if QT_CONFIG(qml_locale)
425#endif
427 } else {
429 }
430 return text;
431}
432
434{
435 Q_Q(const QQuickSpinBox);
436 int value;
439 QJSValue loc;
440#if QT_CONFIG(qml_locale)
443#endif
445 } else {
447 }
448 return value;
449}
450
453{
454 Q_D(QQuickSpinBox);
455 d->up = new QQuickIndicatorButton(this);
456 d->down = new QQuickIndicatorButton(this);
457
461#if QT_CONFIG(cursor)
463#endif
464}
465
467{
468 Q_D(QQuickSpinBox);
469 d->removeImplicitSizeListener(d->up->indicator());
470 d->removeImplicitSizeListener(d->down->indicator());
471}
472
481{
482 Q_D(const QQuickSpinBox);
483 return d->from;
484}
485
487{
488 Q_D(QQuickSpinBox);
489 if (d->from == from)
490 return;
491
492 d->from = from;
494 if (isComponentComplete()) {
495 if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) {
496 d->updateUpEnabled();
497 d->updateDownEnabled();
498 }
499 }
500}
501
510{
511 Q_D(const QQuickSpinBox);
512 return d->to;
513}
514
516{
517 Q_D(QQuickSpinBox);
518 if (d->to == to)
519 return;
520
521 d->to = to;
522 emit toChanged();
523 if (isComponentComplete()) {
524 if (!d->setValue(d->value, /* allowWrap = */false, /* modified = */ false)) {
525 d->updateUpEnabled();
526 d->updateDownEnabled();
527 }
528 }
529}
530
537{
538 Q_D(const QQuickSpinBox);
539 return d->value;
540}
541
543{
544 Q_D(QQuickSpinBox);
545 d->setValue(value, /* allowWrap = */ false, /* modified = */ false);
546}
547
556{
557 Q_D(const QQuickSpinBox);
558 return d->stepSize;
559}
560
562{
563 Q_D(QQuickSpinBox);
564 if (d->stepSize == step)
565 return;
566
567 d->stepSize = step;
569}
570
579{
580 Q_D(const QQuickSpinBox);
581 return d->editable;
582}
583
584void QQuickSpinBox::setEditable(bool editable)
585{
586 Q_D(QQuickSpinBox);
587 if (d->editable == editable)
588 return;
589
590#if QT_CONFIG(cursor)
591 if (d->contentItem) {
592 if (editable)
593 d->contentItem->setCursor(Qt::IBeamCursor);
594 else
595 d->contentItem->unsetCursor();
596 }
597#endif
598
599 d->editable = editable;
600 setAccessibleProperty("editable", editable);
602}
603
619{
620 Q_D(const QQuickSpinBox);
621 return d->live;
622}
623
625{
626 Q_D(QQuickSpinBox);
627 if (d->live == live)
628 return;
629
630 d->live = live;
631
632 //make sure to update the value when changing to live
633 if (live)
634 d->contentItemTextChanged();
635
636 emit liveChanged();
637}
638
639#if QT_CONFIG(validator)
660QValidator *QQuickSpinBox::validator() const
661{
662 Q_D(const QQuickSpinBox);
663 return d->validator;
664}
665
666void QQuickSpinBox::setValidator(QValidator *validator)
667{
668 Q_D(QQuickSpinBox);
669 if (d->validator == validator)
670 return;
671
672 d->validator = validator;
673 emit validatorChanged();
674}
675#endif
676
708{
709 Q_D(const QQuickSpinBox);
710 if (!d->textFromValue.isCallable()) {
711 QQmlEngine *engine = qmlEngine(this);
712 if (engine)
713 d->textFromValue = engine->evaluate(QStringLiteral("(function(value, locale) { return Number(value).toLocaleString(locale, 'f', 0); })"));
714 }
715 return d->textFromValue;
716}
717
719{
720 Q_D(QQuickSpinBox);
721 if (!callback.isCallable()) {
722 qmlWarning(this) << "textFromValue must be a callable function";
723 return;
724 }
725 d->textFromValue = callback;
727}
728
756{
757 Q_D(const QQuickSpinBox);
758 if (!d->valueFromText.isCallable()) {
759 QQmlEngine *engine = qmlEngine(this);
760 if (engine)
761 d->valueFromText = engine->evaluate(QStringLiteral("(function(text, locale) { return Number.fromLocaleString(locale, text); })"));
762 }
763 return d->valueFromText;
764}
765
767{
768 Q_D(QQuickSpinBox);
769 if (!callback.isCallable()) {
770 qmlWarning(this) << "valueFromText must be a callable function";
771 return;
772 }
773 d->valueFromText = callback;
775}
776
792{
793 Q_D(const QQuickSpinBox);
794 return d->up;
795}
796
812{
813 Q_D(const QQuickSpinBox);
814 return d->down;
815}
816
828Qt::InputMethodHints QQuickSpinBox::inputMethodHints() const
829{
830 Q_D(const QQuickSpinBox);
831 return d->inputMethodHints;
832}
833
834void QQuickSpinBox::setInputMethodHints(Qt::InputMethodHints hints)
835{
836 Q_D(QQuickSpinBox);
837 if (d->inputMethodHints == hints)
838 return;
839
840 d->inputMethodHints = hints;
841 emit inputMethodHintsChanged();
842}
843
856{
857 Q_D(const QQuickSpinBox);
858 return d->contentItem && d->contentItem->property("inputMethodComposing").toBool();
859}
860
870{
871 Q_D(const QQuickSpinBox);
872 return d->wrap;
873}
874
876{
877 Q_D(QQuickSpinBox);
878 if (d->wrap == wrap)
879 return;
880
881 d->wrap = wrap;
882 if (d->value == d->from || d->value == d->to) {
883 d->updateUpEnabled();
884 d->updateDownEnabled();
885 }
886 emit wrapChanged();
887}
888
905{
906 Q_D(const QQuickSpinBox);
907 return d->displayText;
908}
909
918{
919 Q_D(QQuickSpinBox);
920 d->increase(false);
921}
922
931{
932 Q_D(QQuickSpinBox);
933 d->decrease(false);
934}
935
937{
938 Q_D(QQuickSpinBox);
940
941 // When an editable SpinBox gets focus, it must pass on the focus to its editor.
942 if (d->editable && d->contentItem && !d->contentItem->hasActiveFocus())
943 d->contentItem->forceActiveFocus(event->reason());
944}
945
947{
948 Q_D(QQuickSpinBox);
950 d->updateHover(event->position());
951 event->ignore();
952}
953
955{
956 Q_D(QQuickSpinBox);
958 d->updateHover(event->position());
959 event->ignore();
960}
961
963{
964 Q_D(QQuickSpinBox);
966 d->down->setHovered(false);
967 d->up->setHovered(false);
968 event->ignore();
969}
970
972{
973 Q_D(QQuickSpinBox);
975
976 switch (event->key()) {
977 case Qt::Key_Up:
978 if (d->upEnabled()) {
979 // Update the pressed state before increasing/decreasing in case user code binds
980 // stepSize to up/down.pressed.
981 d->up->setPressed(true);
982 d->increase(true);
983 event->accept();
984 }
985 break;
986
987 case Qt::Key_Down:
988 if (d->downEnabled()) {
989 d->down->setPressed(true);
990 d->decrease(true);
991 event->accept();
992 }
993 break;
994
995 default:
996 break;
997 }
998
999 setAccessibleProperty("pressed", d->up->isPressed() || d->down->isPressed());
1000}
1001
1003{
1004 Q_D(QQuickSpinBox);
1006
1007 if (d->editable && (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return))
1008 d->updateValue();
1009
1010 d->up->setPressed(false);
1011 d->down->setPressed(false);
1012 setAccessibleProperty("pressed", false);
1013}
1014
1016{
1017 Q_D(QQuickSpinBox);
1019 if (event->timerId() == d->delayTimer) {
1020 d->startPressRepeat();
1021 } else if (event->timerId() == d->repeatTimer) {
1022 if (d->up->isPressed())
1023 d->increase(true);
1024 else if (d->down->isPressed())
1025 d->decrease(true);
1026 }
1027}
1028
1029#if QT_CONFIG(wheelevent)
1030void QQuickSpinBox::wheelEvent(QWheelEvent *event)
1031{
1032 Q_D(QQuickSpinBox);
1033 QQuickControl::wheelEvent(event);
1034 if (d->wheelEnabled) {
1035 const QPointF angle = event->angleDelta();
1036 const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / int(QWheelEvent::DefaultDeltasPerStep);
1037 d->stepBy(qRound(d->effectiveStepSize() * delta), true);
1038 }
1039}
1040#endif
1041
1043{
1044 Q_D(QQuickSpinBox);
1046
1048 if (context) {
1051 }
1052}
1053
1055{
1056 Q_D(QQuickSpinBox);
1059
1061 if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) {
1062 d->updateDisplayText();
1063 d->updateUpEnabled();
1064 d->updateDownEnabled();
1065 }
1066}
1067
1069{
1070 Q_D(QQuickSpinBox);
1072 if (d->editable && change == ItemActiveFocusHasChanged && !value.boolValue)
1073 d->updateValue();
1074}
1075
1077{
1078 Q_D(QQuickSpinBox);
1079 if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
1080 disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
1082 }
1083
1084 if (newItem) {
1085 newItem->setActiveFocusOnTab(true);
1086 if (d->activeFocus)
1087 newItem->forceActiveFocus(d->focusReason);
1088#if QT_CONFIG(cursor)
1089 if (d->editable)
1090 newItem->setCursor(Qt::IBeamCursor);
1091#endif
1092
1093 if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
1094 connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
1096 }
1097 }
1098}
1099
1100void QQuickSpinBox::localeChange(const QLocale &newLocale, const QLocale &oldLocale)
1101{
1102 Q_D(QQuickSpinBox);
1103 QQuickControl::localeChange(newLocale, oldLocale);
1104 d->updateDisplayText();
1105}
1106
1108{
1110}
1111
1112#if QT_CONFIG(accessibility)
1113QAccessible::Role QQuickSpinBox::accessibleRole() const
1114{
1115 return QAccessible::SpinBox;
1116}
1117
1118void QQuickSpinBox::accessibilityActiveChanged(bool active)
1119{
1120 Q_D(QQuickSpinBox);
1121 QQuickControl::accessibilityActiveChanged(active);
1122
1123 if (active)
1124 setAccessibleProperty("editable", d->editable);
1125}
1126#endif
1127
1129
1130#include "moc_qquickspinbox_p.cpp"
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:469
\reentrant
Definition qfont.h:20
\inmodule QtGui
Definition qevent.h:245
QJSValue evaluate(const QString &program, const QString &fileName=QString(), int lineNumber=1, QStringList *exceptionStackTrace=nullptr)
Evaluates program, using lineNumber as the base line number, and returns the result of the evaluation...
static QJSValue fromReturnedValue(QV4::ReturnedValue d)
Definition qjsvalue_p.h:189
The QJSValue class acts as a container for Qt/JavaScript data types.
Definition qjsvalue.h:31
bool isCallable() const
Returns true if this QJSValue is a function, otherwise returns false.
Definition qjsvalue.cpp:445
QJSValue call(const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, passing args as arguments to the function, and using the globalObj...
Definition qjsvalue.cpp:681
qint32 toInt() const
Returns the signed 32-bit integer value of this QJSValue, using the conversion rules described in \l{...
Definition qjsvalue.cpp:545
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
Definition qjsvalue.cpp:473
The QKeyEvent class describes a key event.
Definition qevent.h:423
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
Definition qlocale.h:936
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition qlocale.cpp:1962
static QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
Definition qobject_p.h:298
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
Definition qobject_p.h:327
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1433
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4187
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qpoint.h:214
The QQmlContext class defines a context within a QML engine.
Definition qqmlcontext.h:25
static QV4::ExecutionEngine * getV4Engine(QQmlEngine *e)
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
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)
QQuickDeferredPointer< QQuickItem > contentItem
virtual void handleUngrab()
virtual bool handleRelease(const QPointF &point, ulong timestamp)
virtual bool handleMove(const QPointF &point, ulong timestamp)
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.
virtual void localeChange(const QLocale &newLocale, const QLocale &oldLocale)
void classBegin() override
Invoked after class creation, but before any properties have been set.
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
bool setAccessibleProperty(const char *propertyName, const QVariant &value)
static QQuickIndicatorButtonPrivate * get(QQuickIndicatorButton *button)
void executeIndicator(bool complete=false)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
void setFiltersChildMouseEvents(bool filter)
Sets whether pointer events intended for this item's children should be filtered through this item.
virtual void hoverEnterEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
Q_INVOKABLE QPointF mapFromItem(const QQuickItem *item, const QPointF &point) const
Maps the given point in item's coordinate system to the equivalent point within this item's coordinat...
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.
virtual void hoverMoveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
virtual Q_INVOKABLE bool contains(const QPointF &point) const
\qmlmethod bool QtQuick::Item::contains(point point)
void setEnabled(bool)
void setAcceptedMouseButtons(Qt::MouseButtons buttons)
Sets the mouse buttons accepted by this item to buttons.
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
bool isEnabled() const
Q_INVOKABLE void forceActiveFocus()
\qmlmethod point QtQuick::Item::mapToItem(Item item, real x, real y) \qmlmethod point QtQuick::Item::...
virtual void keyReleaseEvent(QKeyEvent *event)
This event handler can be reimplemented in a subclass to receive key release events for an item.
ItemChange
Used in conjunction with QQuickItem::itemChange() to notify the item about certain types of changes.
Definition qquickitem.h:143
@ ItemActiveFocusHasChanged
Definition qquickitem.h:150
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void setActiveFocusOnTab(bool)
Allows the user to select from a set of preset values.
void handleUngrab() override
int evaluateValueFromText(const QString &text) const
bool handleMove(const QPointF &point, ulong timestamp) override
bool handleRelease(const QPointF &point, ulong timestamp) override
Qt::InputMethodHints inputMethodHints
void decrease(bool modified)
void itemImplicitWidthChanged(QQuickItem *item) override
QQuickIndicatorButton * up
bool handlePress(const QPointF &point, ulong timestamp) override
QQuickIndicatorButton * down
bool stepBy(int steps, bool modified)
int boundValue(int value, bool wrap) const
int effectiveStepSize() const
bool setValue(int value, bool wrap, bool modified)
void itemImplicitHeightChanged(QQuickItem *item) override
QString evaluateTextFromValue(int val) const
void updateHover(const QPointF &pos)
void increase(bool modified)
QPalette defaultPalette() const override
void setDisplayText(const QString &displayText)
QQuickIndicatorButton * up
void keyPressEvent(QKeyEvent *event) override
This event handler can be reimplemented in a subclass to receive key press events for an item.
bool isInputMethodComposing() const
void setStepSize(int step)
void timerEvent(QTimerEvent *event) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override
void focusInEvent(QFocusEvent *event) override
This event handler can be reimplemented in a subclass to receive focus-in 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 setValueFromText(const QJSValue &callback)
void setValue(int value)
void stepSizeChanged()
void textFromValueChanged()
void classBegin() override
Invoked after class creation, but before any properties have been set.
QJSValue textFromValue
void setWrap(bool wrap)
bool isLive() const
\qmlproperty bool QtQuick.Controls::SpinBox::live
void setFrom(int from)
void setTo(int to)
QQuickSpinBox(QQuickItem *parent=nullptr)
void decrease()
\qmlmethod void QtQuick.Controls::SpinBox::decrease()
Qt::InputMethodHints inputMethodHints
void editableChanged()
QQuickIndicatorButton * down
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
QJSValue valueFromText
void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override
void hoverLeaveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
void setTextFromValue(const QJSValue &callback)
bool isEditable() const
\qmlproperty bool QtQuick.Controls::SpinBox::editable
void toChanged()
QFont defaultFont() const override
void setEditable(bool editable)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void hoverEnterEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-enter events for an item.
void fromChanged()
void setInputMethodHints(Qt::InputMethodHints hints)
void increase()
\qmlmethod void QtQuick.Controls::SpinBox::increase()
void hoverMoveEvent(QHoverEvent *event) override
This event handler can be reimplemented in a subclass to receive hover-move events for an item.
void setLive(bool live)
void valueFromTextChanged()
void inputMethodComposingChanged()
static QPalette palette(Scope scope)
static QFont font(Scope scope)
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qcoreevent.h:359
The QValidator class provides validation of input text.
Definition qvalidator.h:24
\inmodule QtCore
Definition qvariant.h:64
QString text
Q_QML_PRIVATE_EXPORT QV4::ReturnedValue wrap(QV4::ExecutionEngine *engine, const QLocale &locale)
Combined button and popup list for selecting options.
@ LeftButton
Definition qnamespace.h:57
@ ArrowCursor
@ IBeamCursor
@ ImhDigitsOnly
@ Key_Return
Definition qnamespace.h:662
@ Key_Enter
Definition qnamespace.h:663
@ Key_Up
Definition qnamespace.h:673
@ Key_Down
Definition qnamespace.h:675
static void * context
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:303
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
QList< QJSValue > QJSValueList
Definition qjsvalue.h:22
constexpr const T & qBound(const T &min, const T &val, const T &max)
Definition qminmax.h:44
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLfloat GLfloat f
GLfloat angle
struct _cl_event * event
GLuint GLfloat * val
GLdouble GLdouble t
Definition qopenglext.h:243
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:76
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:71
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static QT_BEGIN_NAMESPACE const int AUTO_REPEAT_DELAY
static const int AUTO_REPEAT_INTERVAL
static QT_BEGIN_NAMESPACE QAsn1Element wrap(quint8 type, const QAsn1Element &child)
#define QStringLiteral(str)
#define emit
unsigned long ulong
Definition qtypes.h:30
double qreal
Definition qtypes.h:92
myObject disconnect()
[26]
item setCursor(Qt::IBeamCursor)
[1]
QGraphicsItem * item
QJSEngine engine
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
\inmodule QtQuick
Definition qquickitem.h:158