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
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
84{
85 Q_DECLARE_PUBLIC(QQuickSpinBox)
86
87public:
88 int boundValue(int value, bool wrap) const;
89 void updateValue();
90 bool setValue(int value, bool wrap, bool modified);
91 bool stepBy(int steps, bool modified);
92 void increase(bool modified);
93 void decrease(bool modified);
94
95 int effectiveStepSize() const;
96
97 void updateDisplayText();
100
101 bool upEnabled() const;
102 void updateUpEnabled();
103 bool downEnabled() const;
104 void updateDownEnabled();
105 void updateHover(const QPointF &pos);
106
107 void startRepeatDelay();
108 void startPressRepeat();
109 void stopPressRepeat();
110
111 bool handlePress(const QPointF &point, ulong timestamp) override;
112 bool handleMove(const QPointF &point, ulong timestamp) override;
113 bool handleRelease(const QPointF &point, ulong timestamp) override;
114 void handleUngrab() override;
115
118 void itemDestroyed(QQuickItem *item) override;
119
121 int evaluateValueFromText(const QString &text) const;
122
124
125 bool editable = false;
126 bool live = false;
127 bool wrap = false;
128 int from = 0;
129 int to = 99;
130 int value = 0;
131 int stepSize = 1;
132 int delayTimer = 0;
133 int repeatTimer = 0;
137#if QT_CONFIG(validator)
138 QValidator *validator = nullptr;
139#endif
142 Qt::InputMethodHints inputMethodHints = Qt::ImhDigitsOnly;
143};
144
146{
147 bool inverted = from > to;
148 if (!wrap)
149 return inverted ? qBound(to, value, from) : qBound(from, value, to);
150
151 int f = inverted ? to : from;
152 int t = inverted ? from : to;
153 if (value < f)
154 value = t;
155 else if (value > t)
156 value = f;
157
158 return value;
159}
160
162{
163 if (contentItem) {
165 if (text.isValid()) {
166 setValue(evaluateValueFromText(text.toString()), /* allowWrap = */ false, /* modified = */ true);
167 }
168 }
169}
170
171// modified indicates if the value was modified by the user and not programatically
172// this is then passed on to updateDisplayText to indicate that the user has modified
173// the value so it may need to trigger an update of the contentItem's text too
174
175bool QQuickSpinBoxPrivate::setValue(int newValue, bool allowWrap, bool modified)
176{
177 Q_Q(QQuickSpinBox);
178 int correctedValue = newValue;
179 if (q->isComponentComplete())
180 correctedValue = boundValue(newValue, allowWrap);
181
182 if (!modified && newValue == correctedValue && newValue == value)
183 return false;
184
185 const bool emitSignals = (value != correctedValue);
186 value = correctedValue;
187
191
192 // Only emit the signals if the corrected value is not the same as the
193 // original value to avoid unnecessary updates
194 if (emitSignals) {
195 emit q->valueChanged();
196 if (modified)
197 emit q->valueModified();
198 }
199 return true;
200}
201
202bool QQuickSpinBoxPrivate::stepBy(int steps, bool modified)
203{
204 return setValue(value + steps, wrap, modified);
205}
206
208{
209 setValue(value + effectiveStepSize(), wrap, modified);
210}
211
213{
214 setValue(value - effectiveStepSize(), wrap, modified);
215}
216
218{
219 return from > to ? -1 * stepSize : stepSize;
220}
221
226
228{
229 Q_Q(QQuickSpinBox);
230
231 if (displayText == text)
232 return;
233
235 emit q->displayTextChanged();
236}
237
239{
240 Q_Q(QQuickSpinBox);
241
242 QQuickTextInput *inputTextItem = qobject_cast<QQuickTextInput *>(q->contentItem());
243 if (!inputTextItem)
244 return;
245 QString text = inputTextItem->text();
246#if QT_CONFIG(validator)
247 if (validator)
248 validator->fixup(text);
249#endif
250
251 if (live) {
252 const int enteredVal = evaluateValueFromText(text);
253 const int correctedValue = boundValue(enteredVal, false);
254 if (correctedValue == enteredVal && correctedValue != value) {
255 // If live is true and the text is valid change the value
256 // setValue will set the displayText for us.
257 q->setValue(correctedValue);
258 return;
259 }
260 }
261 // If live is false or the value is not valid, just set the displayText
263}
264
266{
267 const QQuickItem *upIndicator = up->indicator();
268 return upIndicator && upIndicator->isEnabled();
269}
270
272{
273 QQuickItem *upIndicator = up->indicator();
274 if (!upIndicator)
275 return;
276
277 upIndicator->setEnabled(wrap || (from < to ? value < to : value > to));
278}
279
281{
282 const QQuickItem *downIndicator = down->indicator();
283 return downIndicator && downIndicator->isEnabled();
284}
285
287{
288 QQuickItem *downIndicator = down->indicator();
289 if (!downIndicator)
290 return;
291
292 downIndicator->setEnabled(wrap || (from < to ? value > from : value < from));
293}
294
296{
297 Q_Q(QQuickSpinBox);
298 QQuickItem *ui = up->indicator();
299 QQuickItem *di = down->indicator();
300 up->setHovered(ui && ui->isEnabled() && ui->contains(q->mapToItem(ui, pos)));
301 down->setHovered(di && di->isEnabled() && di->contains(q->mapToItem(di, pos)));
302}
303
310
317
319{
320 Q_Q(QQuickSpinBox);
321 if (delayTimer > 0) {
322 q->killTimer(delayTimer);
323 delayTimer = 0;
324 }
325 if (repeatTimer > 0) {
326 q->killTimer(repeatTimer);
327 repeatTimer = 0;
328 }
329}
330
332{
333 Q_Q(QQuickSpinBox);
334 QQuickControlPrivate::handlePress(point, timestamp);
335 QQuickItem *ui = up->indicator();
336 QQuickItem *di = down->indicator();
337 up->setPressed(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(q, point)));
338 down->setPressed(di && di->isEnabled() && di->contains(di->mapFromItem(q, point)));
339
340 bool pressed = up->isPressed() || down->isPressed();
341 q->setAccessibleProperty("pressed", pressed);
342 if (pressed)
344 return true;
345}
346
347bool QQuickSpinBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
348{
349 Q_Q(QQuickSpinBox);
350 QQuickControlPrivate::handleMove(point, timestamp);
351 QQuickItem *ui = up->indicator();
352 QQuickItem *di = down->indicator();
353 up->setHovered(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(q, point)));
355 down->setHovered(di && di->isEnabled() && di->contains(di->mapFromItem(q, point)));
357
358 bool pressed = up->isPressed() || down->isPressed();
359 q->setAccessibleProperty("pressed", pressed);
360 if (!pressed)
362 return true;
363}
364
366{
367 Q_Q(QQuickSpinBox);
368 QQuickControlPrivate::handleRelease(point, timestamp);
369 QQuickItem *ui = up->indicator();
370 QQuickItem *di = down->indicator();
371
372 int oldValue = value;
373 if (up->isPressed()) {
374 if (repeatTimer <= 0 && ui && ui->contains(ui->mapFromItem(q, point)))
375 q->increase();
376 // Retain pressed state until after increasing is done in case user code binds stepSize
377 // to up/down.pressed.
378 up->setPressed(false);
379 } else if (down->isPressed()) {
380 if (repeatTimer <= 0 && di && di->contains(di->mapFromItem(q, point)))
381 q->decrease();
382 down->setPressed(false);
383 }
384 if (value != oldValue)
385 emit q->valueModified();
386
387 q->setAccessibleProperty("pressed", false);
389 return true;
390}
391
393{
394 Q_Q(QQuickSpinBox);
396 up->setPressed(false);
397 down->setPressed(false);
398
399 q->setAccessibleProperty("pressed", false);
401}
402
404{
406 if (item == up->indicator())
407 emit up->implicitIndicatorWidthChanged();
408 else if (item == down->indicator())
409 emit down->implicitIndicatorWidthChanged();
410}
411
413{
415 if (item == up->indicator())
416 emit up->implicitIndicatorHeightChanged();
417 else if (item == down->indicator())
418 emit down->implicitIndicatorHeightChanged();
419}
420
422{
424 if (item == up->indicator())
425 up->setIndicator(nullptr);
426 else if (item == down->indicator())
427 down->setIndicator(nullptr);
428}
429
430
432{
433 Q_Q(const QQuickSpinBox);
434
438 QJSValue loc;
439#if QT_CONFIG(qml_locale)
442 v4->fromData(QMetaType::fromType<QLocale>(), &locale));
443#endif
445 } else {
447 }
448 return text;
449}
450
452{
453 Q_Q(const QQuickSpinBox);
454 int value;
457 QJSValue loc;
458#if QT_CONFIG(qml_locale)
461 v4->fromData(QMetaType::fromType<QLocale>(), &locale));
462#endif
464 } else {
466 }
467 return value;
468}
469
471 : QQuickControl(*(new QQuickSpinBoxPrivate), parent)
472{
473 Q_D(QQuickSpinBox);
474 d->up = new QQuickIndicatorButton(this);
475 d->down = new QQuickIndicatorButton(this);
477
481#if QT_CONFIG(cursor)
483#endif
484}
485
487{
488 Q_D(QQuickSpinBox);
489 d->removeImplicitSizeListener(d->up->indicator());
490 d->removeImplicitSizeListener(d->down->indicator());
491}
492
501{
502 Q_D(const QQuickSpinBox);
503 return d->from;
504}
505
507{
508 Q_D(QQuickSpinBox);
509 if (d->from == from)
510 return;
511
512 d->from = from;
514 if (isComponentComplete()) {
515 if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) {
516 d->updateUpEnabled();
517 d->updateDownEnabled();
518 }
519 }
520}
521
530{
531 Q_D(const QQuickSpinBox);
532 return d->to;
533}
534
536{
537 Q_D(QQuickSpinBox);
538 if (d->to == to)
539 return;
540
541 d->to = to;
542 emit toChanged();
543 if (isComponentComplete()) {
544 if (!d->setValue(d->value, /* allowWrap = */false, /* modified = */ false)) {
545 d->updateUpEnabled();
546 d->updateDownEnabled();
547 }
548 }
549}
550
557{
558 Q_D(const QQuickSpinBox);
559 return d->value;
560}
561
563{
564 Q_D(QQuickSpinBox);
565 d->setValue(value, /* allowWrap = */ false, /* modified = */ false);
566}
567
576{
577 Q_D(const QQuickSpinBox);
578 return d->stepSize;
579}
580
582{
583 Q_D(QQuickSpinBox);
584 if (d->stepSize == step)
585 return;
586
587 d->stepSize = step;
589}
590
599{
600 Q_D(const QQuickSpinBox);
601 return d->editable;
602}
603
604void QQuickSpinBox::setEditable(bool editable)
605{
606 Q_D(QQuickSpinBox);
607 if (d->editable == editable)
608 return;
609
610#if QT_CONFIG(cursor)
611 if (d->contentItem) {
612 if (editable)
613 d->contentItem->setCursor(Qt::IBeamCursor);
614 else
615 d->contentItem->unsetCursor();
616 }
617#endif
618
619 d->editable = editable;
620 setAccessibleProperty("editable", editable);
622}
623
639{
640 Q_D(const QQuickSpinBox);
641 return d->live;
642}
643
645{
646 Q_D(QQuickSpinBox);
647 if (d->live == live)
648 return;
649
650 d->live = live;
651
652 //make sure to update the value when changing to live
653 if (live)
654 d->contentItemTextChanged();
655
656 emit liveChanged();
657}
658
659#if QT_CONFIG(validator)
680QValidator *QQuickSpinBox::validator() const
681{
682 Q_D(const QQuickSpinBox);
683 return d->validator;
684}
685
686void QQuickSpinBox::setValidator(QValidator *validator)
687{
688 Q_D(QQuickSpinBox);
689 if (d->validator == validator)
690 return;
691
692 d->validator = validator;
693 emit validatorChanged();
694}
695#endif
696
728{
729 Q_D(const QQuickSpinBox);
730 if (!d->textFromValue.isCallable()) {
731 QQmlEngine *engine = qmlEngine(this);
732 if (engine)
733 d->textFromValue = engine->evaluate(QStringLiteral("(function(value, locale) { return Number(value).toLocaleString(locale, 'f', 0); })"));
734 }
735 return d->textFromValue;
736}
737
739{
740 Q_D(QQuickSpinBox);
741 if (!callback.isCallable()) {
742 qmlWarning(this) << "textFromValue must be a callable function";
743 return;
744 }
745 d->textFromValue = callback;
747}
748
776{
777 Q_D(const QQuickSpinBox);
778 if (!d->valueFromText.isCallable()) {
779 QQmlEngine *engine = qmlEngine(this);
780 if (engine)
781 d->valueFromText = engine->evaluate(QStringLiteral("(function(text, locale) { return Number.fromLocaleString(locale, text); })"));
782 }
783 return d->valueFromText;
784}
785
787{
788 Q_D(QQuickSpinBox);
789 if (!callback.isCallable()) {
790 qmlWarning(this) << "valueFromText must be a callable function";
791 return;
792 }
793 d->valueFromText = callback;
795}
796
812{
813 Q_D(const QQuickSpinBox);
814 return d->up;
815}
816
832{
833 Q_D(const QQuickSpinBox);
834 return d->down;
835}
836
848Qt::InputMethodHints QQuickSpinBox::inputMethodHints() const
849{
850 Q_D(const QQuickSpinBox);
851 return d->inputMethodHints;
852}
853
854void QQuickSpinBox::setInputMethodHints(Qt::InputMethodHints hints)
855{
856 Q_D(QQuickSpinBox);
857 if (d->inputMethodHints == hints)
858 return;
859
860 d->inputMethodHints = hints;
861 emit inputMethodHintsChanged();
862}
863
876{
877 Q_D(const QQuickSpinBox);
878 return d->contentItem && d->contentItem->property("inputMethodComposing").toBool();
879}
880
890{
891 Q_D(const QQuickSpinBox);
892 return d->wrap;
893}
894
896{
897 Q_D(QQuickSpinBox);
898 if (d->wrap == wrap)
899 return;
900
901 d->wrap = wrap;
902 if (d->value == d->from || d->value == d->to) {
903 d->updateUpEnabled();
904 d->updateDownEnabled();
905 }
906 emit wrapChanged();
907}
908
925{
926 Q_D(const QQuickSpinBox);
927 return d->displayText;
928}
929
938{
939 Q_D(QQuickSpinBox);
940 d->increase(false);
941}
942
951{
952 Q_D(QQuickSpinBox);
953 d->decrease(false);
954}
955
957{
958 Q_D(QQuickSpinBox);
960
961 // When an editable SpinBox gets focus, it must pass on the focus to its editor.
962 if (d->editable && d->contentItem && !d->contentItem->hasActiveFocus())
963 d->contentItem->forceActiveFocus(event->reason());
964}
965
967{
968 Q_D(QQuickSpinBox);
970 d->updateHover(event->position());
971 event->ignore();
972}
973
975{
976 Q_D(QQuickSpinBox);
978 d->updateHover(event->position());
979 event->ignore();
980}
981
983{
984 Q_D(QQuickSpinBox);
986 d->down->setHovered(false);
987 d->up->setHovered(false);
988 event->ignore();
989}
990
992{
993 Q_D(QQuickSpinBox);
995
996 switch (event->key()) {
997 case Qt::Key_Up:
998 if (d->upEnabled()) {
999 // Update the pressed state before increasing/decreasing in case user code binds
1000 // stepSize to up/down.pressed.
1001 d->up->setPressed(true);
1002 d->increase(true);
1003 event->accept();
1004 }
1005 break;
1006
1007 case Qt::Key_Down:
1008 if (d->downEnabled()) {
1009 d->down->setPressed(true);
1010 d->decrease(true);
1011 event->accept();
1012 }
1013 break;
1014
1015 default:
1016 break;
1017 }
1018
1019 setAccessibleProperty("pressed", d->up->isPressed() || d->down->isPressed());
1020}
1021
1023{
1024 Q_D(QQuickSpinBox);
1026
1027 if (d->editable && (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return))
1028 d->updateValue();
1029
1030 d->up->setPressed(false);
1031 d->down->setPressed(false);
1032 setAccessibleProperty("pressed", false);
1033}
1034
1036{
1037 Q_D(QQuickSpinBox);
1039 if (event->timerId() == d->delayTimer) {
1040 d->startPressRepeat();
1041 } else if (event->timerId() == d->repeatTimer) {
1042 if (d->up->isPressed())
1043 d->increase(true);
1044 else if (d->down->isPressed())
1045 d->decrease(true);
1046 }
1047}
1048
1049#if QT_CONFIG(wheelevent)
1050void QQuickSpinBox::wheelEvent(QWheelEvent *event)
1051{
1052 Q_D(QQuickSpinBox);
1053 QQuickControl::wheelEvent(event);
1054 if (d->wheelEnabled) {
1055 const QPointF angle = event->angleDelta();
1056 const qreal delta = (qFuzzyIsNull(angle.y()) ? angle.x() : angle.y()) / int(QWheelEvent::DefaultDeltasPerStep);
1057 d->stepBy(qRound(d->effectiveStepSize() * delta), true);
1058 }
1059}
1060#endif
1061
1073
1075{
1076 Q_D(QQuickSpinBox);
1077 QQuickIndicatorButtonPrivate::get(d->up)->executeIndicator(true);
1078 QQuickIndicatorButtonPrivate::get(d->down)->executeIndicator(true);
1079
1081 if (!d->setValue(d->value, /* allowWrap = */ false, /* modified = */ false)) {
1082 d->updateDisplayText();
1083 d->updateUpEnabled();
1084 d->updateDownEnabled();
1085 }
1086}
1087
1089{
1090 Q_D(QQuickSpinBox);
1092 if (d->editable && change == ItemActiveFocusHasChanged && !value.boolValue)
1093 d->updateValue();
1094}
1095
1097{
1098 Q_D(QQuickSpinBox);
1099 if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
1100 disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
1102 }
1103
1104 if (newItem) {
1105 newItem->setActiveFocusOnTab(true);
1106 if (d->activeFocus)
1107 newItem->forceActiveFocus(static_cast<Qt::FocusReason>(d->focusReason));
1108#if QT_CONFIG(cursor)
1109 if (d->editable)
1110 newItem->setCursor(Qt::IBeamCursor);
1111#endif
1112
1113 if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
1114 connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged);
1116 }
1117 }
1118}
1119
1120void QQuickSpinBox::localeChange(const QLocale &newLocale, const QLocale &oldLocale)
1121{
1122 Q_D(QQuickSpinBox);
1123 QQuickControl::localeChange(newLocale, oldLocale);
1124 d->updateDisplayText();
1125}
1126
1131
1132#if QT_CONFIG(accessibility)
1133QAccessible::Role QQuickSpinBox::accessibleRole() const
1134{
1135 return QAccessible::SpinBox;
1136}
1137
1138void QQuickSpinBox::accessibilityActiveChanged(bool active)
1139{
1140 Q_D(QQuickSpinBox);
1141 QQuickControl::accessibilityActiveChanged(active);
1142
1143 if (active)
1144 setAccessibleProperty("editable", d->editable);
1145}
1146#endif
1147
1149
1150#include "moc_qquickspinbox_p.cpp"
The QFocusEvent class contains event parameters for widget focus events.
Definition qevent.h:470
\reentrant
Definition qfont.h:22
\inmodule QtGui
Definition qevent.h:246
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:197
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:450
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:705
qint32 toInt() const
Returns the signed 32-bit integer value of this QJSValue, using the conversion rules described in \l{...
Definition qjsvalue.cpp:566
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
Definition qjsvalue.cpp:494
The QKeyEvent class describes a key event.
Definition qevent.h:424
static constexpr Policy Preferred
static constexpr Policy Fixed
int toInt(const QString &s, bool *ok=nullptr) const
Returns the int represented by the localized string s.
Definition qlocale.h:955
QString toString(qlonglong i) const
Returns a localized string representation of i.
Definition qlocale.cpp:2052
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:299
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:328
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
Definition qobject.cpp:1470
QVariant property(const char *name) const
Returns the value of the object's name property.
Definition qobject.cpp:4323
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
\inmodule QtCore\reentrant
Definition qpoint.h:217
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)
void itemDestroyed(QQuickItem *item) override
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 setIndicator(QQuickItem *indicator)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
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.
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.
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
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:144
@ ItemActiveFocusHasChanged
Definition qquickitem.h:151
virtual void hoverLeaveEvent(QHoverEvent *event)
This event handler can be reimplemented in a subclass to receive hover-leave events for an item.
Allows the user to select from a set of preset values.
void handleUngrab() override
int evaluateValueFromText(const QString &text) const
void itemDestroyed(QQuickItem *item) override
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:129
\inmodule QtCore
Definition qcoreevent.h:366
The QValidator class provides validation of input text.
Definition qvalidator.h:24
\inmodule QtCore
Definition qvariant.h:65
QString text
Combined button and popup list for selecting options.
@ LeftButton
Definition qnamespace.h:58
@ ArrowCursor
@ IBeamCursor
@ ImhDigitsOnly
@ Key_Return
Definition qnamespace.h:667
@ Key_Enter
Definition qnamespace.h:668
@ Key_Up
Definition qnamespace.h:678
@ Key_Down
Definition qnamespace.h:680
FocusReason
static void * context
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
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:80
QQmlContext * qmlContext(const QObject *obj)
Definition qqml.cpp:75
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:35
double qreal
Definition qtypes.h:187
myObject disconnect()
[26]
item setCursor(Qt::IBeamCursor)
[1]
QGraphicsItem * item
QJSEngine engine
[0]
QV4::ReturnedValue fromData(QMetaType type, const void *ptr, Heap::Object *parent=nullptr, int property=-1, uint flags=0)
\inmodule QtQuick
Definition qquickitem.h:159