summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-11-13 21:41:04 +0100
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2015-01-04 18:33:49 +0100
commit84a3dacf462a4170a7fbc71b012fbb2db2c34a19 (patch)
treec6534f200492cbc27aae9d3c53aa22cf115fc1e2 /tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
parentc61f8df4047a616ffcb5e775fa8e5981b13e193f (diff)
QItemDelegate: let QTextEdit and QPlainTextEdit receive tab keypresses
We already let enter/return key presses to reach text edits instead of closing the editor. Do the same for tab/backtabs. [ChangeLog][QtWidgets][Important behavior changes] QItemDelegate will now not close a QTextEdit/QPlainTextEdit editor when the tab key is pressed; instead, the key will reach the editor. Task-number: QTBUG-3305 Change-Id: Ife9e6fdc5678535c596d1068770b0963134d8d5a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
Diffstat (limited to 'tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index f035094a37..41fa889e83 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1250,11 +1250,19 @@ void tst_QItemDelegate::enterKey_data()
QTest::addColumn<bool>("expectedFocus");
QTest::newRow("lineedit enter") << LineEdit << int(Qt::Key_Enter) << false;
+ QTest::newRow("lineedit return") << LineEdit << int(Qt::Key_Return) << false;
+ QTest::newRow("lineedit tab") << LineEdit << int(Qt::Key_Tab) << false;
+ QTest::newRow("lineedit backtab") << LineEdit << int(Qt::Key_Backtab) << false;
+
QTest::newRow("textedit enter") << TextEdit << int(Qt::Key_Enter) << true;
+ QTest::newRow("textedit return") << TextEdit << int(Qt::Key_Return) << true;
+ QTest::newRow("textedit tab") << TextEdit << int(Qt::Key_Tab) << true;
+ QTest::newRow("textedit backtab") << TextEdit << int(Qt::Key_Backtab) << false;
+
QTest::newRow("plaintextedit enter") << PlainTextEdit << int(Qt::Key_Enter) << true;
QTest::newRow("plaintextedit return") << PlainTextEdit << int(Qt::Key_Return) << true;
- QTest::newRow("plaintextedit tab") << PlainTextEdit << int(Qt::Key_Tab) << false;
- QTest::newRow("lineedit tab") << LineEdit << int(Qt::Key_Tab) << false;
+ QTest::newRow("plaintextedit tab") << PlainTextEdit << int(Qt::Key_Tab) << true;
+ QTest::newRow("plaintextedit backtab") << PlainTextEdit << int(Qt::Key_Backtab) << false;
}
void tst_QItemDelegate::enterKey()
@@ -1312,10 +1320,11 @@ void tst_QItemDelegate::enterKey()
QTest::keyClick(editor, Qt::Key(key));
QApplication::processEvents();
- // The line edit has already been destroyed, so avoid that case.
- if (widget == TextEdit || widget == PlainTextEdit) {
+ if (expectedFocus) {
QVERIFY(!editor.isNull());
- QCOMPARE(editor && editor->hasFocus(), expectedFocus);
+ QVERIFY(editor->hasFocus());
+ } else {
+ QTRY_VERIFY(editor.isNull()); // editor deletion happens via deleteLater
}
}