Advertisement
Guest User

Untitled

a guest
Apr 21st, 2016
1,574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.32 KB | None | 0 0
  1. import QtQuick 2.5
  2. import QtQuick.Window 2.2
  3. import QtQml.Models 2.2
  4. import QtQuick.Controls 1.4
  5. import QtQuick.Layouts 1.3
  6.  
  7. Window {
  8.     visible: true
  9.  
  10.     width: 200
  11.     height: 480
  12.     color: "cyan"
  13.  
  14.     ListModel {
  15.         id: fruitModel
  16.  
  17.         ListElement {
  18.             name: "Apple"
  19.         }
  20.         ListElement {
  21.             name: "Orange"
  22.         }
  23.     }
  24.  
  25.     Component {
  26.         id: delegateComp
  27.  
  28.         RowLayout
  29.         {
  30.             width: parent.width
  31.  
  32.             Text {
  33.                 id: malzemeresultxt
  34.                 font.pixelSize: 15
  35.                 text: name
  36.                 wrapMode: Text.Wrap
  37.                 Layout.fillWidth: true
  38.                 //Layout.maximumWidth: parent.width - 17
  39.             }
  40.  
  41.             Rectangle {
  42.                 id: maldeleteimg
  43.                 width: 10
  44.                 height: 10
  45.                 color: "red"
  46.                 Layout.alignment: Qt.AlignRight
  47.             }
  48.         }
  49.     }
  50.  
  51.     ListView {
  52.         id:malzemelist
  53.  
  54.         anchors {
  55.             top: parent.top
  56.             bottom: button.top; bottomMargin: 10
  57.             left: parent.left
  58.             right: parent.right
  59.         }
  60.  
  61.         spacing: 6
  62.         clip:true
  63.         orientation:ListView.Vertical
  64.         flickableDirection: Flickable.VerticalFlick
  65.         boundsBehavior: Flickable.StopAtBounds
  66.         model: fruitModel
  67.         delegate: delegateComp
  68.     }
  69.  
  70.     Button {
  71.         id: button
  72.         anchors.bottom: parent.bottom
  73.         anchors.horizontalCenter: parent.horizontalCenter
  74.         text: "add fruit with a long name"
  75.  
  76.         onClicked: {
  77.             fruitModel.append({ name: "Banananananananananananananananananananananana" })
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement