Advertisement
Guest User

Untitled

a guest
Aug 26th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 3.06 KB | None | 0 0
  1. import QtQuick 2.11
  2. import QtQuick.Controls 2.2
  3.  
  4. Item {
  5.     property real itemHeight: 30
  6.     property real portColWidthP: 0.35
  7.     property real modelColWidthP: 0.35
  8.     property real uidColWidthP: 0.30
  9.     property int  currentIndex: listView.currentIndex
  10.     property int count: listModel.count
  11.     property var append: listModel.append
  12.     property var clear: listModel.clear
  13.     property var get: listModel.get
  14.  
  15.     Rectangle {
  16.         id: rect
  17.         anchors.fill: parent
  18.         // HEADER
  19.         Component {
  20.             id: header
  21.             Item {
  22.                 z: 2
  23.                 width: rect.width
  24.                 height: itemHeight
  25.                 Rectangle {
  26.                     height: parent.height
  27.                     width: parent.width
  28.                     Row {
  29.                         spacing: 5
  30.                         height: parent.height
  31.                         width: parent.width
  32.                         MyListSubItem {
  33.                             text: "Port"
  34.                             width: parent.width * portColWidthP
  35.                         }
  36.                         MyListSubItem {
  37.                             text: "Model"
  38.                             width: parent.width * modelColWidthP
  39.                         }
  40.                         MyListSubItem {
  41.                             text: "UID"
  42.                             width: parent.width * uidColWidthP
  43.                         }
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.         // DELEGATE
  49.         Component {
  50.             id: listDelegate
  51.             Item {
  52.                 width: rect.width
  53.                 height: itemHeight
  54.                 Row {
  55.                     spacing: 5
  56.                     height: parent.height
  57.                     width: parent.width
  58.                     MyListSubItem {
  59.                         text: port
  60.                         width: parent.width * portColWidthP
  61.                     }
  62.                     MyListSubItem {
  63.                         text: model
  64.                         width: parent.width * modelColWidthP
  65.                     }
  66.                     MyListSubItem {
  67.                         text: uid
  68.                         width: parent.width * uidColWidthP
  69.                     }
  70.                 }
  71.                 MouseArea {
  72.                     anchors.fill: parent
  73.                     onClicked: listView.currentIndex = index;
  74.                 }
  75.             }
  76.         }
  77.         // LIST VIEW
  78.         ListView {
  79.             id: listView
  80.             anchors.fill: parent
  81.             spacing: 5
  82.             clip: true
  83.             interactive: true
  84.             header: header
  85.             headerPositioning: ListView.OverlayHeader
  86.             delegate: listDelegate
  87.             highlight: Rectangle {
  88.                 color: Qt.rgba(1, 0, 0, 0.5);
  89.                 z: 1.1
  90.             }
  91.             model: ListModel {
  92.                 id: listModel
  93.             }
  94.             ScrollBar.vertical: ScrollBar {
  95.                 policy: ScrollBar.AlwaysOn
  96.             }
  97.         }
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement