diff options
author | Kalle Viironen <kalle.viironen@digia.com> | 2011-09-15 13:56:31 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-09-15 13:56:31 (GMT) |
commit | 9463ba63bc7e41a1d6aa320aced392843e31b160 (patch) | |
tree | eb9b897c8d39c8cb9226cf8952eeed6b8cea8cf7 /tests/auto/qgraphicsscene | |
parent | ead8dff4884d6081683b8281db69062413950673 (diff) | |
download | Qt-9463ba63bc7e41a1d6aa320aced392843e31b160.zip Qt-9463ba63bc7e41a1d6aa320aced392843e31b160.tar.gz Qt-9463ba63bc7e41a1d6aa320aced392843e31b160.tar.bz2 |
Fix - QGraphicsTextItem in a tab of QTabWidget cannot get focus
Any QGraphicsTextItems in those tabs which are not the first tab of
QTabWidget, cannot get focus although the tab is current tab of
QTabWidget.But the QGraphicsTextItem in the first tab of QTabWidget can
get focus. i.e. a focus frame (dotted box) appears around the
QGraphicsTextItem. Those QGraphicsTextItems which cannot get focus can
get focus only after the main window is minimized and then maximized.
i.e. After that, a focus frame appears around it.
Task-number: QTBUG-19680
Merge-request: 2676
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index b8741fe..8a26323 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -290,6 +290,7 @@ private slots: void taskQT_3674_doNotCrash(); void taskQTBUG_15977_renderWithDeviceCoordinateCache(); void taskQTBUG_16401_focusItem(); + void taskQTBUG_19680_tabWidgetFocus(); }; void tst_QGraphicsScene::initTestCase() @@ -4711,5 +4712,72 @@ void tst_QGraphicsScene::taskQTBUG_16401_focusItem() QVERIFY(!scene.focusItem()); } +void tst_QGraphicsScene::taskQTBUG_19680_tabWidgetFocus() +{ + QTabWidget tabWidget; + QGraphicsScene scene1; + QGraphicsScene scene2; + QGraphicsView view1(&scene1); + QGraphicsView view2(&scene2); + + tabWidget.show(); + + tabWidget.addTab(&view1, "view1"); + tabWidget.setCurrentWidget(&view1); + + QGraphicsTextItem *textItem1 = scene1.addText("Text1"); + textItem1->setFlags(QGraphicsItem::ItemIsFocusable); + textItem1->setTextInteractionFlags(Qt::TextEditorInteraction); + textItem1->setEnabled(true); + textItem1->setFocus(); + + tabWidget.addTab(&view2, "view2"); + tabWidget.setCurrentWidget(&view2); + + QGraphicsTextItem *textItem2 = scene2.addText("Text2"); + textItem2->setFlags(QGraphicsItem::ItemIsFocusable); + textItem2->setTextInteractionFlags(Qt::TextEditorInteraction); + textItem2->setEnabled(true); + textItem2->setFocus(); + + scene2.clearFocus(); + + view2.clearFocus(); + view2.setEnabled(false); + view2.setInteractive(false); + view2.setVisible(false); + view2.setShown(false); + view2.hide(); + + tabWidget.clearFocus(); + tabWidget.setEnabled(false); + tabWidget.setShown(false); + tabWidget.setVisible(false); + tabWidget.hide(); + + tabWidget.setFocus(); + tabWidget.setEnabled(true); + tabWidget.activateWindow(); + tabWidget.setShown(true); + tabWidget.setVisible(true); + tabWidget.show(); + + view2.setFocus(); + view2.setEnabled(true); + view2.activateWindow(); + view2.setInteractive(true); + view2.setVisible(true); + view2.setShown(true); + view2.show(); + + QTest::qWaitForWindowShown(&view2); + QApplication::setActiveWindow(&tabWidget); + + textItem2->setFocus(); + + QVERIFY(scene2.isActive()); + QVERIFY(textItem2->hasFocus()); +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" |