Advertisement
Guest User

Untitled

a guest
Jul 30th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.91 KB | None | 0 0
  1. import QtQuick 2.12
  2. import QtQuick.Window 2.12
  3. import QtQuick.Controls 2.12
  4.  
  5. ApplicationWindow {
  6.     visible: true
  7.     width: 640
  8.     height: 480
  9.     title: qsTr("Hello World")
  10.  
  11.  
  12.  
  13.     header: ToolBar {
  14.         ToolButton{
  15.             text: qsTr("Menu")
  16.             onClicked: drawer.open()
  17.         }
  18.     }
  19.  
  20.     Drawer {
  21.         id: drawer
  22.         width: 200
  23.         height: parent.height
  24.         Page {
  25.             anchors.fill: parent
  26.  
  27.             ListModel {
  28.                 id: myModel
  29.             }
  30.  
  31.             Component {
  32.                 id: addFormComponent
  33.                 Popup {
  34.                     id: popupItem
  35.                     anchors.centerIn: parent
  36.                     parent: Overlay.overlay
  37.  
  38.                     Column {
  39.                         TextField {
  40.                             id: nameField
  41.                         }
  42.  
  43.                         Button {
  44.                             text: qsTr("Add")
  45.                             onClicked: {
  46.                                 myModel.append({"name": nameField.text})
  47.                                 popupItem.close()
  48.                                 popupItem.destroy()
  49.                             }
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.  
  55.             header: ToolBar {
  56.                 Row {
  57.                     ToolButton {
  58.                         text: qsTr("Add")
  59.                         onClicked: {
  60.                             var popup = addFormComponent.createObject(this)
  61.                             popup.open()
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.  
  67.             ListView {
  68.                 anchors.fill: parent
  69.                 delegate: ItemDelegate {
  70.                     width: parent.width
  71.                     text: name
  72.                 }
  73.                 model: myModel
  74.             }
  75.         }
  76.     }
  77.  
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement