summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-09 08:01:10 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-09-09 15:18:07 (GMT)
commit948038f077ea413ab7aa7634d1c9987ec7ab50f6 (patch)
tree4f1142819abe81fedad25e276b28900f1b16c157 /tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
parentc44402453593cbdf2eafa66f6ee23d17aacf44fd (diff)
downloadQt-948038f077ea413ab7aa7634d1c9987ec7ab50f6.zip
Qt-948038f077ea413ab7aa7634d1c9987ec7ab50f6.tar.gz
Qt-948038f077ea413ab7aa7634d1c9987ec7ab50f6.tar.bz2
Only active QGraphicsScenes can have active input focus.
This change ensures that only active scenes can have active input focus items. If you try to set input focus on items that are in an inactive scene, these items will gain input focus only when the scene is activated. For scenes attached to a view, this change should only fix the bug that you could have a blinking line edit in a scene when the view is inactive, meaning you couldn't type into the line edit. For scenes that have no view, you now must activate the scene in order to give the items active input focus. This will affect those who use QGraphicsScene with custom key and focus handling. Reviewed-by: brad
Diffstat (limited to 'tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp')
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 20803a5..5296788 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -438,6 +438,8 @@ void tst_QGraphicsWidget::focusWidget()
SubQGraphicsWidget *parent = new SubQGraphicsWidget;
QCOMPARE(parent->focusWidget(), (QGraphicsWidget *)0);
QGraphicsScene scene;
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &windowActivate);
scene.addItem(parent);
QFETCH(int, childCount);
@@ -459,7 +461,9 @@ void tst_QGraphicsWidget::focusWidget()
void tst_QGraphicsWidget::focusWidget2()
{
QGraphicsScene scene;
-
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &windowActivate);
+
QGraphicsWidget *widget = new QGraphicsWidget;
EventSpy focusInSpy(widget, QEvent::FocusIn);
EventSpy focusOutSpy(widget, QEvent::FocusOut);
@@ -561,6 +565,9 @@ void tst_QGraphicsWidget::focusPolicy_data()
void tst_QGraphicsWidget::focusPolicy()
{
QGraphicsScene scene;
+ QEvent windowActivate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &windowActivate);
+
SubQGraphicsWidget *widget = new SubQGraphicsWidget;
scene.addItem(widget);
QCOMPARE(Qt::NoFocus, widget->focusPolicy());
@@ -788,6 +795,12 @@ void tst_QGraphicsWidget::initStyleOption()
{
QGraphicsScene scene;
QGraphicsView view(&scene);
+ view.show();
+#ifdef Q_WS_X11
+ qt_x11_wait_for_window_manager(&view);
+#endif
+ QTest::qWait(250);
+
view.setAlignment(Qt::AlignTop | Qt::AlignLeft);
SubQGraphicsWidget *widget = new SubQGraphicsWidget;
widget->setAcceptsHoverEvents(true);
@@ -1183,6 +1196,8 @@ void tst_QGraphicsWidget::setTabOrderAndReparent()
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
#endif
+ QTest::qWait(250);
+
int i;
QGraphicsWidget *w1, *w2, *w3, *w4;
for (i = 1; i < 4; ++i) {