From ccd3bf0871b81dfc09bb469b161f32dfb47ee53e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 22 Oct 2019 13:01:38 +0200 Subject: Ensure that child windows are visible again when showing their parent When a window is closed, then it will cause the child windows to be closed as well as a result. Therefore in order to ensure that they are shown again as a result, we need to remove the WA_WState_ExplicitShowHide attribute if the widget was not already hidden before. This enables us to test for this attribute when calling showChildren(), so that if the window has a windowHandle then we can make sure that this widget is shown again. Fixes: QTBUG-73021 Change-Id: I1186242b889899dfcd38d782a67567348e2055ee Reviewed-by: Ulf Hermann --- tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index a95d6e76b3..ebf08883fd 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -399,6 +399,7 @@ private slots: void tabletTracking(); void closeEvent(); + void closeWithChildWindow(); private: bool ensureScreenSize(int width, int height); @@ -11115,5 +11116,27 @@ void tst_QWidget::closeEvent() QCOMPARE(widget.closeCount, 1); } +void tst_QWidget::closeWithChildWindow() +{ + QWidget widget; + auto childWidget = new QWidget(&widget); + childWidget->setAttribute(Qt::WA_NativeWindow); + childWidget->windowHandle()->create(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + widget.windowHandle()->close(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + // Check that the child window inside the window is now visible + QVERIFY(childWidget->isVisible()); + + // Now explicitly hide the childWidget + childWidget->hide(); + widget.windowHandle()->close(); + widget.show(); + QVERIFY(QTest::qWaitForWindowExposed(&widget)); + QVERIFY(!childWidget->isVisible()); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" -- cgit v1.2.3 From b1004c7d0a5d7abbacd687fd41a5b2683e62b27d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 29 Oct 2019 09:44:50 +0100 Subject: If only family is set, prefer that in the families list after resolving If a font with only a family set is resolved with one that has been setup with setFamilies() then the family needs to be prepended to the families list after resolving. This is so that the font still prefers the one set as just a family with no famillies set. This also amends the QFontDialog test to account for this too. [ChangeLog][QtGui][Text] Resolving a font that just has a family set with families set will prepend the family to the families so that it is still the first preference for the font. Task-number: QTBUG-46322 Change-Id: Icc4005732f95b2b4c684e592b06b31e133270e44 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'tests/auto/widgets') diff --git a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp index a5aaf62855..c8e6e8fcd0 100644 --- a/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp +++ b/tests/auto/widgets/dialogs/qfontdialog/tst_qfontdialog.cpp @@ -225,6 +225,7 @@ void tst_QFontDialog::qtbug_41513_stylesheetStyle() // The fontdialog sets the styleName, when the fontdatabase knows the style name. resultFont.setStyleName(testFont.styleName()); + testFont.setFamilies(QStringList(testFont.family())); QCOMPARE(resultFont, testFont); // reset stylesheet -- cgit v1.2.3