diff options
author | Benjamin Port <benjamin.port@ben2367.fr> | 2013-06-10 16:51:15 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-06-21 19:05:56 +0200 |
commit | a418a544ce1050a85d4a04981e363ce91a8e4211 (patch) | |
tree | 3c67a3585fbf581938c6f22dcfc9f74dcbce5799 /src/widgets/widgets/qtextedit.cpp | |
parent | bab630e4bf0a9a651a7e15d0d15f9c0f57ab5e46 (diff) |
Show QTextEdit placeholder even when focused
Useful to have the same behavior in QLineEdit and QTextEdit.
Change-Id: I02d6ac0a6072403c7aa3e8f76a728c46a9d66b14
Reviewed-by: David Faure (KDE) <faure@kde.org>
Diffstat (limited to 'src/widgets/widgets/qtextedit.cpp')
-rw-r--r-- | src/widgets/widgets/qtextedit.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index da4998ca71..4e0c682493 100644 --- a/src/widgets/widgets/qtextedit.cpp +++ b/src/widgets/widgets/qtextedit.cpp @@ -779,8 +779,7 @@ QTextDocument *QTextEdit::document() const \brief the editor placeholder text Setting this property makes the editor display a grayed-out - placeholder text as long as the document() is empty and the widget doesn't - have focus. + placeholder text as long as the document() is empty. By default, this property contains an empty string. @@ -797,7 +796,7 @@ void QTextEdit::setPlaceholderText(const QString &placeholderText) Q_D(QTextEdit); if (d->placeholderText != placeholderText) { d->placeholderText = placeholderText; - if (!hasFocus() && d->control->document()->isEmpty()) + if (d->control->document()->isEmpty()) d->viewport->update(); } } @@ -1529,7 +1528,7 @@ void QTextEdit::paintEvent(QPaintEvent *e) Q_D(QTextEdit); QPainter p(d->viewport); d->paint(&p, e); - if (!d->placeholderText.isEmpty() && !hasFocus() && d->control->document()->isEmpty()) { + if (!d->placeholderText.isEmpty() && d->control->document()->isEmpty()) { QColor col = palette().text().color(); col.setAlpha(128); p.setPen(col); @@ -1749,8 +1748,6 @@ void QTextEdit::focusInEvent(QFocusEvent *e) } QAbstractScrollArea::focusInEvent(e); d->sendControlEvent(e); - if (!d->placeholderText.isEmpty() && d->control->document()->isEmpty()) - d->viewport->update(); } /*! \reimp @@ -1760,8 +1757,6 @@ void QTextEdit::focusOutEvent(QFocusEvent *e) Q_D(QTextEdit); QAbstractScrollArea::focusOutEvent(e); d->sendControlEvent(e); - if (!d->placeholderText.isEmpty() && d->control->document()->isEmpty()) - d->viewport->update(); } /*! \reimp |