diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2019-04-16 16:32:08 +0200 |
commit | 6630937e63ae5797487b86743a7733c8ae5cc42c (patch) | |
tree | 3d53dacf6430f9099e1fb20835881205de674961 /src/widgets/widgets/qlineedit.cpp | |
parent | 37ed6dae00640f9cc980ffda05347c12a7eb5d7e (diff) | |
parent | c7af193d2e49e9f10b86262e63d8d13abf72b5cf (diff) |
Merge commit 'dev' into 'wip/cmake-merge'
Change-Id: I176c40d031be26a1dd1cf08843e448a660598783
Diffstat (limited to 'src/widgets/widgets/qlineedit.cpp')
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 242a4405ca..02aa703289 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -315,7 +315,7 @@ QString QLineEdit::text() const void QLineEdit::setText(const QString& text) { Q_D(QLineEdit); - d->control->setText(text); + d->setText(text); } /*! @@ -488,7 +488,10 @@ void QLineEdit::setClearButtonEnabled(bool enable) QAction *clearAction = new QAction(d->clearButtonIcon(), QString(), this); clearAction->setEnabled(!isReadOnly()); clearAction->setObjectName(QLatin1String(clearButtonActionNameC)); - d->addAction(clearAction, 0, QLineEdit::TrailingPosition, QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText); + + int flags = QLineEditPrivate::SideWidgetClearButton | QLineEditPrivate::SideWidgetFadeInWithText; + auto widgetAction = d->addAction(clearAction, nullptr, QLineEdit::TrailingPosition, flags); + widgetAction->setVisible(!text().isEmpty()); } else { QAction *clearAction = findChild<QAction *>(QLatin1String(clearButtonActionNameC)); Q_ASSERT(clearAction); @@ -583,7 +586,7 @@ void QLineEdit::setEchoMode(EchoMode mode) #ifndef QT_NO_VALIDATOR /*! - Returns a pointer to the current input validator, or 0 if no + Returns a pointer to the current input validator, or \nullptr if no validator has been set. \sa setValidator() @@ -1480,8 +1483,11 @@ bool QLineEdit::event(QEvent * e) } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkEnabled(false); - if (d->control->hasAcceptableInput() || d->control->fixup()) + if (d->edited && (d->control->hasAcceptableInput() + || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } } #endif @@ -1678,6 +1684,7 @@ void QLineEdit::mouseDoubleClickEvent(QMouseEvent* e) /*! \fn void QLineEdit::inputRejected() + \since 5.12 This signal is emitted when the user presses a key that is not considered to be acceptable input. For example, if a key press @@ -1887,7 +1894,6 @@ void QLineEdit::focusInEvent(QFocusEvent *e) /*!\reimp */ - void QLineEdit::focusOutEvent(QFocusEvent *e) { Q_D(QLineEdit); @@ -1910,8 +1916,10 @@ void QLineEdit::focusOutEvent(QFocusEvent *e) #endif if (reason != Qt::PopupFocusReason || !(QApplication::activePopupWidget() && QApplication::activePopupWidget()->parentWidget() == this)) { - if (hasAcceptableInput() || d->control->fixup()) + if (d->edited && (hasAcceptableInput() || d->control->fixup())) { emit editingFinished(); + d->edited = false; + } } #ifdef QT_KEYPAD_NAVIGATION d->control->setCancelText(QString()); |