Skip to content

Instantly share code, notes, and snippets.

@mottosso
Created November 30, 2015 07:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mottosso/3ee99ca3c5e581ebd781 to your computer and use it in GitHub Desktop.
Save mottosso/3ee99ca3c5e581ebd781 to your computer and use it in GitHub Desktop.
StackView Example
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
ApplicationWindow {
title: "My StackView"
width: 400
height: 300
/*!
Start by tailoring your Component
This could come from another file, in this case
I'm simply using a Rectangle and some text.
*/
Component {
id: view
Rectangle {
property alias name: tex.text
Text {
id: tex
anchors.centerIn: parent
}
}
}
ColumnLayout {
anchors.fill: parent
RowLayout {
height: 30
Layout.fillWidth: true
Button {
text: "Previous"
/*! To "pop" means to discard the current Component */
onClicked: stack.pop()
}
Button {
text: "Next"
/*! To "push" means to add the next Component */
onClicked: stack.push({
item: view,
properties: {
"color": "steelblue",
"name": "An awesome name"
}
})
}
}
/*! Finally, don't forget to set an initial component */
StackView {
id: stack
Layout.fillWidth: true
Layout.fillHeight: true
initialItem: Rectangle {
color: "brown"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment