Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.16 KB | None | 0 0
  1. import QtQuick 2.9
  2. import QtQuick.Controls 2.3
  3.  
  4. ApplicationWindow {
  5.     visible: true
  6.     width: 512
  7.     height: 380
  8.     title: qsTr("Demo")
  9.  
  10.     header: ToolBar {
  11.         Row {
  12.             ToolButton {
  13.                 text: "push1"
  14.                 onClicked: stack1.push(firstItem.createObject())
  15.             }
  16.  
  17.             ToolButton {
  18.                 text: "pop1"
  19.                 onClicked: stack1.pop().destroy()
  20.             }
  21.         }
  22.     }
  23.  
  24.     Component {
  25.         id: firstItem
  26.         Item {
  27.             Button {
  28.                 text: "push2"
  29.                 onClicked: stack2.push(secondItem.createObject())
  30.             }
  31.  
  32.             Component {
  33.                 id: secondItem
  34.                 Item {
  35.                     Component.onDestruction: console.log("second item destroyed")
  36.                 }
  37.             }
  38.         }
  39.     }
  40.  
  41.     StackView {
  42.         id: stack1
  43.         width: parent.width/2
  44.         height: parent.height
  45.         initialItem: Item {}
  46.     }
  47.  
  48.     StackView {
  49.         id: stack2
  50.         x: parent.width/2
  51.         width: parent.width/2
  52.         height: parent.height
  53.         initialItem: Item {}
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement