diff options
author | Nils Jeisecke <nils.jeisecke@saltation.com> | 2019-02-13 15:28:11 +0100 |
---|---|---|
committer | Nils Jeisecke <nils.jeisecke@saltation.com> | 2019-02-15 14:03:07 +0000 |
commit | 1d0f808c7dc708f5ec8093f09f332615b94f4318 (patch) | |
tree | 4eaa3caef49aab0e3884625720ed001f496d8236 /tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | |
parent | 1ffb45a3682c864f8071b8b19da49c9a7761dd5e (diff) |
TextEdit: Fix persistentSelection for readonly controls
TextEdit items with readOnly:true do not clear the selection on losing
focus which is expected with persistentSelection:false.
The reason is that a readonly TextEdit does never show a blinking cursor
and thus the selection clearing within setCursorVisible never happens.
This change adapts the implementation from TextInput.
Fixes: QTBUG-50587
Change-Id: Ie66baaa0ccbc006359473862d8e9dbecd46a59f6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp')
-rw-r--r-- | tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp index f32da44daa..ce2a8eb257 100644 --- a/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp +++ b/tests/auto/quick/qquicktextedit/tst_qquicktextedit.cpp @@ -1262,6 +1262,34 @@ void tst_qquicktextedit::persistentSelection() edit->setFocus(true); QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + // QTBUG-50587 (persistentSelection with readOnly) + edit->setReadOnly(true); + + edit->setPersistentSelection(false); + QCOMPARE(edit->persistentSelection(), false); + QCOMPARE(spy.count(), 2); + + edit->select(1, 4); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(false); + QCOMPARE(edit->property("selected").toString(), QString()); + + edit->setFocus(true); + QCOMPARE(edit->property("selected").toString(), QString()); + + edit->setPersistentSelection(true); + QCOMPARE(edit->persistentSelection(), true); + QCOMPARE(spy.count(), 3); + + edit->select(1, 4); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(false); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); + + edit->setFocus(true); + QCOMPARE(edit->property("selected").toString(), QLatin1String("ell")); } void tst_qquicktextedit::selectionOnFocusOut() |