Here is the actual QML code contained in the example click package:
import QtQuick 2.4 import QtQuick.Window 2.2 QtObject { readonly property var allWindows: [] property var windowFactory: Component { Window { onClosing: destroy() Component.onCompleted: allWindows.push(this) Component.onDestruction: { for (var w in allWindows) { if (this === allWindows[w]) { allWindows.splice(w, 1) return } } } Rectangle { anchors { fill: parent margins: 20 } color: Qt.rgba(Math.random(), Math.random(), Math.random(), 1) } MouseArea { anchors.fill: parent onClicked: windowFactory.createObject(null).show() } } } property var applicationMonitor: Connections { target: Qt.application onAboutToQuit: console.log("quitting application, %1 windows open".arg(allWindows.length)) } Component.onCompleted: windowFactory.createObject(null).show() }
Here is the actual QML code contained in the example click package:
import QtQuick 2.4 .onCompleted: allWindows. push(this) .onDestruction: {
allWindows .splice( w, 1) Math.random( ), Math.random(), Math.random(), 1)
anchors. fill: parent createObject( null).show( ) log("quitting application, %1 windows open".arg( allWindows. length) ) onCompleted: windowFactory. createObject( null).show( )
import QtQuick.Window 2.2
QtObject {
readonly property var allWindows: []
property var windowFactory: Component {
Window {
onClosing: destroy()
Component
Component
for (var w in allWindows) {
if (this === allWindows[w]) {
return
}
}
}
Rectangle {
anchors {
fill: parent
margins: 20
}
color: Qt.rgba(
}
MouseArea {
onClicked: windowFactory.
}
}
}
property var applicationMonitor: Connections {
target: Qt.application
onAboutToQuit: console.
}
Component.
}