main.qml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import QtQuick 2.9
  2. import QtQuick.Controls 2.2
  3. ApplicationWindow {
  4. id: window
  5. visible: true
  6. width: 640
  7. height: 480
  8. title: qsTr("Stack")
  9. header: ToolBar {
  10. contentHeight: 36
  11. MenuBackButton {
  12. id: menuButton
  13. anchors.verticalCenter: parent.verticalCenter
  14. anchors.left: parent.left
  15. anchors.leftMargin: 8
  16. width: 24
  17. height: 24
  18. state: stackView.depth > 1 ? "back" : "menu"
  19. onClicked: {
  20. drawer.open()
  21. }
  22. onBack: {
  23. stackView.pop()
  24. }
  25. }
  26. Label {
  27. text: stackView.currentItem.title
  28. anchors.centerIn: parent
  29. }
  30. }
  31. Drawer {
  32. id: drawer
  33. width: window.width * 0.66
  34. height: window.height
  35. Column {
  36. anchors.fill: parent
  37. ItemDelegate {
  38. text: qsTr("Settings")
  39. width: parent.width
  40. onClicked: {
  41. if (stackView.depth > 1) {
  42. stackView.pop()
  43. }
  44. stackView.push("SettingsForm.qml")
  45. drawer.close()
  46. }
  47. }
  48. }
  49. }
  50. StackView {
  51. id: stackView
  52. initialItem: "HomeForm.qml"
  53. anchors.fill: parent
  54. }
  55. }