diff options
-rw-r--r-- | examples/widgets/widgets/lineedits/window.cpp | 5 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit.cpp | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/examples/widgets/widgets/lineedits/window.cpp b/examples/widgets/widgets/lineedits/window.cpp index 0749e8d4fd..a0871e7c77 100644 --- a/examples/widgets/widgets/lineedits/window.cpp +++ b/examples/widgets/widgets/lineedits/window.cpp @@ -55,6 +55,7 @@ Window::Window() echoComboBox->addItem(tr("No Echo")); echoLineEdit = new QLineEdit; + echoLineEdit->setPlaceholderText("Placeholder Text"); echoLineEdit->setFocus(); //! [0] @@ -68,6 +69,7 @@ Window::Window() validatorComboBox->addItem(tr("Double validator")); validatorLineEdit = new QLineEdit; + validatorLineEdit->setPlaceholderText("Placeholder Text"); //! [1] //! [2] @@ -80,6 +82,7 @@ Window::Window() alignmentComboBox->addItem(tr("Right")); alignmentLineEdit = new QLineEdit; + alignmentLineEdit->setPlaceholderText("Placeholder Text"); //! [2] //! [3] @@ -93,6 +96,7 @@ Window::Window() inputMaskComboBox->addItem(tr("License key")); inputMaskLineEdit = new QLineEdit; + inputMaskLineEdit->setPlaceholderText("Placeholder Text"); //! [3] //! [4] @@ -104,6 +108,7 @@ Window::Window() accessComboBox->addItem(tr("True")); accessLineEdit = new QLineEdit; + accessLineEdit->setPlaceholderText("Placeholder Text"); //! [4] //! [5] diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 65969a7ebb..869570b0e3 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1801,7 +1801,7 @@ void QLineEdit::paintEvent(QPaintEvent *) int minRB = qMax(0, -fm.minRightBearing()); if (d->control->text().isEmpty()) { - if (!hasFocus() && !d->placeholderText.isEmpty()) { + if (!d->placeholderText.isEmpty()) { QColor col = pal.text().color(); col.setAlpha(128); QPen oldpen = p.pen(); @@ -1810,7 +1810,6 @@ void QLineEdit::paintEvent(QPaintEvent *) QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); p.drawText(lineRect, va, elidedText); p.setPen(oldpen); - return; } } |