summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtabbar
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-06 20:45:41 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2023-11-09 20:57:43 +0100
commit83e92e25573f98e7530a3dfcaf02910f3932107f (patch)
treecee9f7f06969974234aa781c108f57c47c22a9fe /tests/auto/widgets/widgets/qtabbar
parent96e3d06b6f216fb802acc6dd1a7dca113f782508 (diff)
QTabWidget/Bar: ignore hidden tabs for key events
Even a tab was hidden it could be accessed with the key navigation or a scroll event which lead to painting artifacts. Pick-to: 6.6 6.5 5.15 Fixes: QTBUG-101219 Task-number: QTBUG-63038 Change-Id: I58be694eef5f86cccecbe528891a39a4acdda15f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/widgets/widgets/qtabbar')
-rw-r--r--tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
index 00d09873b2..7aede22441 100644
--- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
+++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp
@@ -50,6 +50,7 @@ private slots:
void hideTab_data();
void hideTab();
void hideAllTabs();
+ void checkHiddenTab();
void setElideMode_data();
void setElideMode();
@@ -367,6 +368,25 @@ void tst_QTabBar::hideAllTabs()
QVERIFY(sizeHint.width() < prevSizeHint.width());
}
+void tst_QTabBar::checkHiddenTab()
+{
+ QTabBar tabbar;
+
+ tabbar.addTab("foo");
+ tabbar.addTab("bar");
+ tabbar.addTab("baz");
+ tabbar.setCurrentIndex(0);
+ tabbar.setTabVisible(1, false);
+
+ QKeyEvent keyRight(QKeyEvent::KeyPress, Qt::Key_Right, Qt::NoModifier);
+ QVERIFY(QApplication::sendEvent(&tabbar, &keyRight));
+ QCOMPARE(tabbar.currentIndex(), 2);
+
+ QKeyEvent keyLeft(QKeyEvent::KeyPress, Qt::Key_Left, Qt::NoModifier);
+ QVERIFY(QApplication::sendEvent(&tabbar, &keyLeft));
+ QCOMPARE(tabbar.currentIndex(), 0);
+}
+
void tst_QTabBar::setElideMode_data()
{
QTest::addColumn<int>("tabElideMode");