gpt4 book ai didi

qt - 在QML ListView中的元素之间需要页边距

转载 作者:行者123 更新时间:2023-12-04 10:18:07 28 4
gpt4 key购买 nike

我需要QML ListView中元素之间的边距。有了这段代码,我得到了元素列的边距,但是我需要每个元素之间的边距:

    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
}

我得到列表元素的框之间的边距。工作正常吗?我需要在ListView的每个元素之间添加边距。我需要像这样的列:
Element  "Apple"
margin
Element "Banana"

最佳答案

添加:

spacing: value

到您的 ListView属性。

关于qt - 在QML ListView中的元素之间需要页边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24360869/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com