Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.77 KB | None | 0 0
  1. Rectangle {
  2.     id: rectangle
  3.     width: 600
  4.     height: 200
  5.     color: "white"
  6.     border.width: 2
  7.     border.color: "blue"
  8.     anchors.centerIn: parent
  9.  
  10.     ListView {
  11.         id: listView
  12.         focus: true
  13.  
  14.         width: 350
  15.         height: 50
  16.         anchors.centerIn: parent
  17.         clip: true
  18.  
  19.         orientation: ListView.Horizontal
  20.         preferredHighlightBegin: 125
  21.         preferredHighlightEnd: 225
  22.         highlightMoveDuration: 200
  23.         highlightRangeMode: ListView.StrictlyEnforceRange
  24.  
  25.         model: ListModel {
  26.             ListElement {
  27.                 name: "Grey"
  28.                 colorCode: "grey"
  29.             }
  30.  
  31.             ListElement {
  32.                 name: "Red"
  33.                 colorCode: "red"
  34.             }
  35.  
  36.             ListElement {
  37.                 name: "Blue"
  38.                 colorCode: "blue"
  39.             }
  40.  
  41.             ListElement {
  42.                 name: "Green"
  43.                 colorCode: "green"
  44.             }
  45.         }
  46.         delegate: Rectangle {
  47.             width: 100
  48.             height: 50
  49.             color: colorCode
  50.  
  51.             Text {
  52.                 text: name
  53.                 font.bold: true
  54.                 anchors.centerIn: parent
  55.                 color: "white"
  56.             }
  57.         }
  58.     }
  59.  
  60.     Text {
  61.         text: qsTr("center")
  62.         anchors.bottom: listView.top
  63.         anchors.horizontalCenter: parent.horizontalCenter
  64.     }
  65.  
  66.     Text {
  67.         text: qsTr("left")
  68.         anchors.top: listView.bottom
  69.         anchors.right: listView.left
  70.     }
  71.  
  72.     Text {
  73.         text: qsTr("right")
  74.         anchors.top: listView.bottom
  75.         anchors.left: listView.right
  76.     }
  77. }
  78.  
  79. Text {
  80.     anchors.bottom: rectangle.top
  81.     anchors.left: rectangle.left
  82.     text: qsTr("parent")
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement