diff options
Diffstat (limited to 'src/widgets/itemviews/qabstractitemdelegate.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemdelegate.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index c6161a4680..23e8ef0901 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE The second approach is to handle user events directly by reimplementing editorEvent(). - \sa {model-view-programming}{Model/View Programming}, {Pixelator Example}, + \sa {model-view-programming}{Model/View Programming}, QStyledItemDelegate, QStyle */ @@ -480,12 +480,13 @@ bool QAbstractItemDelegatePrivate::editorEventFilter(QObject *object, QEvent *ev // If the application loses focus while editing, then the focus needs to go back // to the itemview when the editor closes. This ensures that when the application // is active again it will have the focus on the itemview as expected. + QWidget *editorParent = editor->parentWidget(); const bool manuallyFixFocus = (event->type() == QEvent::FocusOut) && !editor->hasFocus() && - editor->parentWidget() && + editorParent && (static_cast<QFocusEvent *>(event)->reason() == Qt::ActiveWindowFocusReason); emit q->closeEditor(editor, QAbstractItemDelegate::NoHint); if (manuallyFixFocus) - editor->parentWidget()->setFocus(); + editorParent->setFocus(); } #ifndef QT_NO_SHORTCUT } else if (event->type() == QEvent::ShortcutOverride) { @@ -513,6 +514,14 @@ bool QAbstractItemDelegatePrivate::tryFixup(QWidget *editor) return e->hasAcceptableInput(); } } +#endif +#if QT_CONFIG(spinbox) + // Give a chance to the spinbox to interpret the text and emit + // the appropriate signals before committing data. + if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(editor)) { + if (!sb->keyboardTracking()) + sb->interpretText(); + } #else Q_UNUSED(editor); #endif // QT_CONFIG(lineedit) |