Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need margins between elements in QML ListView

Tags:

listview

qt

qml

I need margins between elements in QML ListView. With this code I get margin of column of elements, but I need margin between each element:

    ListModel {
         id: listModel

         ListElement {
             name: "Apple"
         }
         ListElement {
             name: "Banana"
         }
 }

Component {
    id: listDelegate

    Rectangle {
    width: 250; height: 100
    anchors.margins: 30
    color: "green"

    Text {
        id: itexItem
        anchors.leftMargin: 20
        anchors.verticalCenter: parent.verticalCenter
        font.pixelSize: 40
        text: name
    }

    }
}
ListView {
       id: listView
       anchors.fill: parent;
       anchors.margins: 50
       model: listModel
       delegate: listDelegate
       focus: true
 }

I get margin between box of list element. Is it work fine. I need margin between each element of ListView. I need column like:

Element  "Apple"
margin
Element  "Banana"
like image 541
Andrew P. Avatar asked Jun 23 '14 07:06

Andrew P.


1 Answers

Add:

spacing: value

to your ListView properties.

like image 146
prajmus Avatar answered Oct 23 '22 21:10

prajmus