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>
This commit is contained in:
Benjamin Port 2013-06-10 16:51:15 +02:00 committed by The Qt Project
parent bab630e4bf
commit a418a544ce

View File

@ -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