Advertisement
ajith_97

TreeViewQML

Sep 8th, 2022
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.15 KB | None | 0 0
  1. import QtQuick
  2. import QtQuick.Controls 2.15
  3. import QtQuick.Layouts 1.15
  4.  
  5. import TreeViewExample 1.0
  6.  
  7. ApplicationWindow {
  8.     id: root
  9.     width: 500
  10.     height: 500
  11.     visible: true
  12.     title: qsTr("Tree Example")
  13.  
  14.     Drawer {
  15.         id: topDrawer
  16.  
  17.         width: root.width
  18.  
  19.         modal: false
  20.         edge: Qt.TopEdge
  21.  
  22.         closePolicy: Drawer.NoAutoClose
  23.         dragMargin: 0
  24.  
  25.         contentData: RowLayout {
  26.             anchors.fill: parent
  27.  
  28.             Label {
  29.                 text: "Root item"
  30.                 Layout.leftMargin: 10
  31.             }
  32.         }
  33.  
  34.         Component.onCompleted: topDrawer.open()
  35.     }
  36.  
  37.     Item {
  38.         Keys.onPressed: {
  39.             if(event.key === Qt.Key_F1) {
  40.                 if(topDrawer.opened()) {
  41.                     topDrawer.close()
  42.                 } else {
  43.                     topDrawer.open()
  44.                 }
  45.             }
  46.         }
  47.     }
  48.  
  49.     Shortcut {
  50.         sequence: "Esc"
  51.         onActivated: {
  52.             if(topDrawer.opened) {
  53.                 topDrawer.close()
  54.             } else {
  55.                 topDrawer.open()
  56.             }
  57.         }
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement