Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
If Loader loads Window, set its transient parent to the Loader's window
This makes the Item { Loader { sourceComponent: Window { } } } case consistent with the Item { Window { } } case: the inner Window is transient for the outer Window. It works even if the Loader's Window has a visible: true declaration: in that case, until now, the Loader's Window would become visible at component creation time, before the outer Item became visible. So the test to check whether it had a transient parent did not work. We now change the delayed-visibility mechanism in QQuickWindowQmlImpl to wait for the parent Item to acquire a window of its own rather than waiting for the transient-parent-if-any to become visible. It should still take care of all the old cases too, e.g. in the Window { Window { } } case, the inner Window's QObject parent is actually the QQuickRootItem. (Amends 701255c76f671f100338a799f0194bf10e26c9d1) [ChangeLog][QtQuick][QQuickWindow] When a Window is declared inside another Item or Window, the window will not be created until the parent window is created. This allows it to have the correct transientParent and be managed as a transient window. Task-number: QTBUG-52944 Change-Id: Iaf4aafbd696f6e8dd0eec1d02db8bd181483bd07 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
- Loading branch information
Showing
6 changed files
with
166 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/auto/quick/qquickloader/data/itemLoaderItemWindow.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Window 2.1 | ||
|
||
Item { | ||
width: 400 | ||
height: 400 | ||
objectName: "root Item" | ||
|
||
Loader { | ||
sourceComponent: Rectangle { | ||
objectName: "yellow rectangle" | ||
x: 50; y: 50; width: 300; height: 300 | ||
color: "yellow" | ||
Window { | ||
objectName: "red transient Window" | ||
width: 100 | ||
height: 100 | ||
visible: true // makes it harder, because it wants to become visible before root has a window | ||
color: "red" | ||
title: "red" | ||
flags: Qt.Dialog | ||
onVisibilityChanged: console.log("visibility " + visibility) | ||
onVisibleChanged: console.log("visible " + visible) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import QtQuick 2.0 | ||
import QtQuick.Window 2.1 | ||
|
||
Item { | ||
width: 400 | ||
height: 400 | ||
objectName: "root Item" | ||
|
||
Loader { | ||
sourceComponent: Window { | ||
objectName: "red transient Window" | ||
width: 100 | ||
height: 100 | ||
visible: true // makes it harder, because it wants to become visible before root has a window | ||
color: "red" | ||
title: "red" | ||
flags: Qt.Dialog | ||
onVisibilityChanged: console.log("visibility " + visibility) | ||
onVisibleChanged: console.log("visible " + visible) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters