Skip to content

Instantly share code, notes, and snippets.

Created August 21, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/372c58e7f53531bd6e51950d611e33a7 to your computer and use it in GitHub Desktop.
Save anonymous/372c58e7f53531bd6e51950d611e33a7 to your computer and use it in GitHub Desktop.
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"
}
}
}
}
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