9#include <QtGui/qguiapplication.h>
10#include <QtGui/qstylehints.h>
12#include <QtQml/qqmlinfo.h>
13#if QT_CONFIG(qml_locale)
14#include <QtQml/private/qqmllocale_p.h>
16#include <QtQml/private/qqmlengine_p.h>
17#include <QtQuick/private/qquicktextinput_p.h>
91 bool stepBy(
int steps,
bool modified);
137#if QT_CONFIG(validator)
147 bool inverted =
from >
to;
165 if (
text.isValid()) {
178 int correctedValue = newValue;
179 if (
q->isComponentComplete())
180 correctedValue =
boundValue(newValue, allowWrap);
182 if (!modified && newValue == correctedValue && newValue ==
value)
185 const bool emitSignals = (
value != correctedValue);
186 value = correctedValue;
195 emit q->valueChanged();
197 emit q->valueModified();
235 emit q->displayTextChanged();
242 QQuickTextInput *inputTextItem = qobject_cast<QQuickTextInput *>(
q->contentItem());
246#if QT_CONFIG(validator)
248 validator->fixup(
text);
253 const int correctedValue =
boundValue(enteredVal,
false);
254 if (correctedValue == enteredVal && correctedValue !=
value) {
257 q->setValue(correctedValue);
268 return upIndicator && upIndicator->
isEnabled();
283 return downIndicator && downIndicator->
isEnabled();
300 up->
setHovered(ui && ui->isEnabled() && ui->contains(
q->mapToItem(ui,
pos)));
337 up->
setPressed(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(
q, point)));
338 down->
setPressed(di && di->isEnabled() && di->contains(di->mapFromItem(
q, point)));
341 q->setAccessibleProperty(
"pressed", pressed);
353 up->
setHovered(ui && ui->isEnabled() && ui->contains(ui->mapFromItem(
q, point)));
355 down->
setHovered(di && di->isEnabled() && di->contains(di->mapFromItem(
q, point)));
359 q->setAccessibleProperty(
"pressed", pressed);
372 int oldValue =
value;
374 if (repeatTimer <= 0 && ui && ui->
contains(ui->mapFromItem(
q, point)))
380 if (repeatTimer <= 0 && di && di->
contains(di->mapFromItem(
q, point)))
384 if (
value != oldValue)
385 emit q->valueModified();
387 q->setAccessibleProperty(
"pressed",
false);
399 q->setAccessibleProperty(
"pressed",
false);
407 emit up->implicitIndicatorWidthChanged();
409 emit down->implicitIndicatorWidthChanged();
416 emit up->implicitIndicatorHeightChanged();
418 emit down->implicitIndicatorHeightChanged();
439#if QT_CONFIG(qml_locale)
458#if QT_CONFIG(qml_locale)
489 d->removeImplicitSizeListener(
d->up->indicator());
490 d->removeImplicitSizeListener(
d->down->indicator());
515 if (!
d->setValue(
d->value,
false,
false)) {
516 d->updateUpEnabled();
517 d->updateDownEnabled();
544 if (!
d->setValue(
d->value,
false,
false)) {
545 d->updateUpEnabled();
546 d->updateDownEnabled();
565 d->setValue(
value,
false,
false);
584 if (
d->stepSize == step)
611 if (
d->contentItem) {
615 d->contentItem->unsetCursor();
654 d->contentItemTextChanged();
659#if QT_CONFIG(validator)
686void QQuickSpinBox::setValidator(
QValidator *validator)
689 if (
d->validator == validator)
692 d->validator = validator;
693 emit validatorChanged();
730 if (!
d->textFromValue.isCallable()) {
735 return d->textFromValue;
742 qmlWarning(
this) <<
"textFromValue must be a callable function";
745 d->textFromValue = callback;
778 if (!
d->valueFromText.isCallable()) {
783 return d->valueFromText;
790 qmlWarning(
this) <<
"valueFromText must be a callable function";
793 d->valueFromText = callback;
851 return d->inputMethodHints;
857 if (
d->inputMethodHints == hints)
860 d->inputMethodHints = hints;
861 emit inputMethodHintsChanged();
878 return d->contentItem &&
d->contentItem->property(
"inputMethodComposing").toBool();
902 if (
d->value ==
d->from ||
d->value ==
d->to) {
903 d->updateUpEnabled();
904 d->updateDownEnabled();
927 return d->displayText;
962 if (
d->editable &&
d->contentItem && !
d->contentItem->hasActiveFocus())
963 d->contentItem->forceActiveFocus(
event->reason());
970 d->updateHover(
event->position());
978 d->updateHover(
event->position());
986 d->down->setHovered(
false);
987 d->up->setHovered(
false);
996 switch (
event->key()) {
998 if (
d->upEnabled()) {
1001 d->up->setPressed(
true);
1008 if (
d->downEnabled()) {
1009 d->down->setPressed(
true);
1030 d->up->setPressed(
false);
1031 d->down->setPressed(
false);
1039 if (
event->timerId() ==
d->delayTimer) {
1040 d->startPressRepeat();
1041 }
else if (
event->timerId() ==
d->repeatTimer) {
1042 if (
d->up->isPressed())
1044 else if (
d->down->isPressed())
1049#if QT_CONFIG(wheelevent)
1050void QQuickSpinBox::wheelEvent(QWheelEvent *
event)
1053 QQuickControl::wheelEvent(
event);
1054 if (
d->wheelEnabled) {
1057 d->stepBy(
qRound(
d->effectiveStepSize() * delta),
true);
1081 if (!
d->setValue(
d->value,
false,
false)) {
1082 d->updateDisplayText();
1083 d->updateUpEnabled();
1084 d->updateDownEnabled();
1099 if (
QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) {
1105 newItem->setActiveFocusOnTab(
true);
1108#if QT_CONFIG(cursor)
1113 if (
QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) {
1124 d->updateDisplayText();
1132#if QT_CONFIG(accessibility)
1133QAccessible::Role QQuickSpinBox::accessibleRole()
const
1135 return QAccessible::SpinBox;
1138void QQuickSpinBox::accessibilityActiveChanged(
bool active)
1141 QQuickControl::accessibilityActiveChanged(active);
1150#include "moc_qquickspinbox_p.cpp"
The QFocusEvent class contains event parameters for widget focus events.
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)
The QJSValue class acts as a container for Qt/JavaScript data types.
bool isCallable() const
Returns true if this QJSValue is a function, otherwise returns false.
QJSValue call(const QJSValueList &args=QJSValueList()) const
Calls this QJSValue as a function, passing args as arguments to the function, and using the globalObj...
qint32 toInt() const
Returns the signed 32-bit integer value of this QJSValue, using the conversion rules described in \l{...
QString toString() const
Returns the string value of this QJSValue, as defined in \l{ECMA-262} section 9.8,...
The QKeyEvent class describes a key event.
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.
QString toString(qlonglong i) const
Returns a localized string representation of i.
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)
static bool disconnect(const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiverPrivate, Func2 slot)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
virtual void timerEvent(QTimerEvent *event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
QVariant property(const char *name) const
Returns the value of the object's name property.
The QPalette class contains color groups for each widget state.
\inmodule QtCore\reentrant
The QQmlContext class defines a context within a QML engine.
static QV4::ExecutionEngine * getV4Engine(QQmlEngine *e)
The QQmlEngine class provides an environment for instantiating QML components.
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)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
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 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.
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.
@ ItemActiveFocusHasChanged
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 contentItemTextChanged()
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 textFromValueChanged()
void classBegin() override
Invoked after class creation, but before any properties have been set.
bool isLive() const
\qmlproperty bool QtQuick.Controls::SpinBox::live
QQuickSpinBox(QQuickItem *parent=nullptr)
void decrease()
\qmlmethod void QtQuick.Controls::SpinBox::decrease()
Qt::InputMethodHints inputMethodHints
QQuickIndicatorButton * down
void itemChange(ItemChange change, const ItemChangeData &value) override
Called when change occurs for this item.
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
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 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 valueFromTextChanged()
void inputMethodComposingChanged()
static QPalette palette(Scope scope)
static QFont font(Scope scope)
\macro QT_RESTRICTED_CAST_FROM_ASCII
The QValidator class provides validation of input text.
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
bool qFuzzyIsNull(qfloat16 f) noexcept
int qRound(qfloat16 d) noexcept
QList< QJSValue > QJSValueList
constexpr const T & qBound(const T &min, const T &val, const T &max)
static bool contains(const QJsonArray &haystack, unsigned needle)
GLdouble GLdouble GLdouble GLdouble q
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
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)
myObject disconnect()
[26]
item setCursor(Qt::IBeamCursor)
[1]
QV4::ReturnedValue fromData(QMetaType type, const void *ptr, Heap::Object *parent=nullptr, int property=-1, uint flags=0)