diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-04-04 16:18:39 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-04-05 07:34:21 +0000 |
commit | ed64115cbf11a758a9cacd2bd34f3af5603f73b7 (patch) | |
tree | aee8d02bf8503499b579d3521d50728ea2d93c79 /src/quicktemplates2/qquickspinbox.cpp | |
parent | 0704f76d4793929b79a1fefd6c9f83ac69e70307 (diff) |
Set explicit cursors on all interactive controls
For example, if you have a floating button on top of a text editor,
hovering the button must change the cursor from the editor's ibeam
cursor to an arrow cursor. This applies to all interactive controls
that call setAcceptedMouseButtons(). If a control blocks mouse events,
it should not use some random cursor from another control underneath.
Task-number: QTBUG-59629
Change-Id: I8a6ae306bbc76a9b22377361cb19cf9c3a872d31
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickspinbox.cpp')
-rw-r--r-- | src/quicktemplates2/qquickspinbox.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 657102c3..b70366ea 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -351,6 +351,9 @@ QQuickSpinBox::QQuickSpinBox(QQuickItem *parent) setFlag(ItemIsFocusScope); setFiltersChildMouseEvents(true); setAcceptedMouseButtons(Qt::LeftButton); +#if QT_CONFIG(cursor) + setCursor(Qt::ArrowCursor); +#endif } /*! @@ -470,6 +473,15 @@ void QQuickSpinBox::setEditable(bool editable) if (d->editable == editable) return; +#if QT_CONFIG(cursor) + if (d->contentItem) { + if (editable) + d->contentItem->setCursor(Qt::IBeamCursor); + else + d->contentItem->unsetCursor(); + } +#endif + d->editable = editable; emit editableChanged(); } @@ -905,11 +917,16 @@ void QQuickSpinBox::itemChange(ItemChange change, const ItemChangeData &value) void QQuickSpinBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) { + Q_D(QQuickSpinBox); if (QQuickTextInput *oldInput = qobject_cast<QQuickTextInput *>(oldItem)) disconnect(oldInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged); if (newItem) { newItem->setActiveFocusOnTab(true); +#if QT_CONFIG(cursor) + if (d->editable) + newItem->setCursor(Qt::IBeamCursor); +#endif if (QQuickTextInput *newInput = qobject_cast<QQuickTextInput *>(newItem)) connect(newInput, &QQuickTextInput::inputMethodComposingChanged, this, &QQuickSpinBox::inputMethodComposingChanged); |