Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.47 KB | None | 0 0
  1. import QtQuick 2.12
  2. import QtQuick.Controls 2.12
  3.  
  4. ApplicationWindow {
  5.     visible: true
  6.     width: 640
  7.     height: 480
  8.     title: qsTr("Hello World")
  9.  
  10.     ListModel {
  11.         id: listModel
  12.         ListElement { name: "Max"; lastname: "Vor"; counter: 0 }
  13.     }
  14.  
  15.     ListView {
  16.         anchors.fill: parent
  17.         model: listModel
  18.         delegate: ItemDelegate {
  19.             icon.source: "qrc:/updater.png"
  20.             icon.color: "transparent"
  21.             text: 'Item name: %1\nLastName: %2\nCounter: %3'
  22.                                     .arg(name)
  23.                                   .arg(lastname)
  24.                                   .arg(counter)
  25.             width: parent.width
  26.             onClicked: {
  27.                 popup.modelItem = model
  28.                 popup.open()
  29.             }
  30.         }
  31.     }
  32.     Popup {
  33.         id: popup
  34.         parent: overlay
  35.         anchors.centerIn: parent
  36.         property var modelItem
  37.         Column {
  38.             Label {
  39.                 text: popup.modelItem ? 'Item name: %1\nLastName: %2\nCounter: %3'
  40.                                         .arg(popup.modelItem.name)
  41.                                       .arg(popup.modelItem.lastname)
  42.                                       .arg(popup.modelItem.counter): ""
  43.             }
  44.             SpinBox {
  45.                 value: (popup.modelItem ? popup.modelItem.counter : 0)
  46.                 onValueModified: popup.modelItem.counter = value
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement