Created
August 21, 2016 14:23
-
-
Save anonymous/372c58e7f53531bd6e51950d611e33a7 to your computer and use it in GitHub Desktop.
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
import QtQuick 2.7 | |
import QtQuick.Layouts 1.1 | |
import QtQuick.Controls 2.0 | |
ApplicationWindow { | |
id: window | |
visible: true | |
height: 300 | |
ColumnLayout{ | |
Button { | |
text: "Push with createQmlObject" | |
onClicked: { | |
var qmlString = "import QtQuick 2.5;Rectangle {Component.onDestruction: console.log(\"Blue Destruction Beginning!\");color:\"blue\";}" | |
var obj = Qt.createQmlObject(qmlString, stackView, "testView") | |
stackView.push(obj) | |
} | |
} | |
Button { | |
text: "Push With createComponent" | |
onClicked: { | |
var component = Qt.createComponent("./Page1.qml") | |
switch (component.status) { | |
case Component.Ready: | |
//var form = component.createObject() | |
stackView.push(component) // Everithing is ok - I see "Red Destruction Beginning!" | |
break | |
case Component.Error: | |
console.log(component.errorString()) | |
break | |
} | |
} | |
} | |
Button { | |
text: "Pop" | |
onClicked: stackView.pop() | |
} | |
StackView { | |
id: stackView | |
height: 100 | |
width: 100 | |
initialItem: Rectangle { | |
Component.onDestruction: console.log( | |
"Green Destruction Beginning!") | |
color: "green" | |
} | |
} | |
} | |
} |
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
import QtQuick 2.5 | |
Rectangle { | |
Component.onDestruction: console.log("Red Destruction Beginning!") | |
color: "red" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment