main.qml 1.6 KB

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