diff options
author | Axel Spoerl <axel.spoerl@qt.io> | 2023-08-10 11:09:58 +0200 |
---|---|---|
committer | Axel Spoerl <axel.spoerl@qt.io> | 2023-08-14 17:11:27 +0000 |
commit | 4c7cac682fddfad274325ff82b5f212543e5373a (patch) | |
tree | 5b44e60526bc66b4726e33423b9f3337060e5176 /tests/auto/widgets/widgets/qplaintextedit | |
parent | 0e3815a7a85befe49b87370842814f5c23b6c8c4 (diff) |
QPlainTextEdit: update placeholder text when document is empty
When the placeholder text is changed after having been displayed, it
doesn't get updated on the screen any more, unless the entire viewport
is updated, e.g. because of a document change or a focus event.
This patch simplifies QPlainTextEditPrivate::updatePlaceHolderVisibility()
to update the visibility if the text document is empty.
It replaces the member QPlainTextEditorPrivate::placeholderVisible
by the function isPlaceHolderTextVisible(). It returns true, if the
document is empty and a placeholder text exists, and otherwise false.
It adapts and corrects tst_QPlainTextEdit::placeHolderVisibility():
- usage of new member function instead of data member.
- do not expect an empty placeholder to be visible.
Fixes: QTBUG-115831
Pick-to: 6.6 6.5 6.2
Change-Id: Ic4427ce7f7f1b8cde89957b9de0b978bd34ba923
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qplaintextedit')
-rw-r--r-- | tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index ed68c735d4..bec4a55814 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -1830,7 +1830,7 @@ void tst_QPlainTextEdit::placeholderVisibility_data() QTest::addColumn<QList<SetupCommand>>("setupCommands"); QTest::addColumn<bool>("placeholderVisible"); QTest::addRow("no placeholder set + no text set") - << QList<SetupCommand>{} << true; + << QList<SetupCommand>{} << false; QTest::addRow("no placeholder set + text set or text set + no placeholder set") << QList<SetupCommand>{ SetContent } << false; QTest::addRow("no placeholder set + text set + empty text set") @@ -1840,7 +1840,7 @@ void tst_QPlainTextEdit::placeholderVisibility_data() << QList<SetupCommand>{ ClearContent, SetContent } << false; QTest::addRow("empty placeholder set + no text set") - << QList<SetupCommand>{ ClearPlaceHolder } << true; + << QList<SetupCommand>{ ClearPlaceHolder } << false; QTest::addRow("empty placeholder set + text set") << QList<SetupCommand>{ ClearPlaceHolder, SetContent } << false; @@ -1917,7 +1917,7 @@ void tst_QPlainTextEdit::placeholderVisibility() plainTextEdit.show(); QVERIFY(QTest::qWaitForWindowExposed(&plainTextEdit)); - QTRY_VERIFY(plainTextEdit_d->placeholderVisible == placeholderVisible); + QTRY_VERIFY(plainTextEdit_d->isPlaceHolderTextVisible() == placeholderVisible); } |