import QtQuick 2.12
import QtQuick.Window 2.12
import QtQml 2.3
import QtQuick.Controls 2.5
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ListView {
anchors.fill : parent
model: ListModel {
ListElement {
name : 'Jie'
count : 10
}
ListElement {
name : 'Li'
count : 16
}
ListElement {
name : 'Wang'
count : 88
}
ListElement {
name : 'Wu'
count : 56
}
ListElement {
name : 'JieGe'
count : 10
}
ListElement {
name : 'LiMeng'
count : 16
}
ListElement {
name : 'WangWu'
count : 88
}
ListElement {
name : 'Wu'
count : 56
}
}
// 滚动条的附加属性,这里的语义是将滚动条添加到 ListView
ScrollBar.vertical: ScrollBar {
policy: ScrollBar.AlwaysOn // 滚动条ce'l策略,这里是永远显示
}
delegate: Text {
text: name + ' ' + count
color: 'red'
font.pointSize: 20
}
}
}
qml ListView添加滚动条示例
最新推荐文章于 2023-07-31 21:07:31 发布