From a418a544ce1050a85d4a04981e363ce91a8e4211 Mon Sep 17 00:00:00 2001 From: Benjamin Port Date: Mon, 10 Jun 2013 16:51:15 +0200 Subject: [PATCH] Show QTextEdit placeholder even when focused Useful to have the same behavior in QLineEdit and QTextEdit. Change-Id: I02d6ac0a6072403c7aa3e8f76a728c46a9d66b14 Reviewed-by: David Faure (KDE) --- src/widgets/widgets/qtextedit.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp index da4998ca71b..4e0c6824939 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