QML ListView几个常用且非常重要的属性
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
Window {
visible: true
title: qsTr("Hello World")
ListView{
id:listView
anchors.fill: parent
model: 10
snapMode: ListView.SnapOneItem
orientation:ListView.Horizontal
delegate: Rectangle{
width: listView.width
height: listView.height
color: index%2 ? "red":"yellow"
Label{
anchors.centerIn: parent
font.pointSize: 100
text: index
}
}
}
}
snapMode: ListView.SnapOneItem // 将切换模式设置为单张切换;
orientation:ListView.Horizontal //将列表改成水平浏览模式。
highlightRangeMode: ListView.StrictlyEnforceRange //切换 item 的时候将 currentIndex 也跟随着变化
boundsBehavior:Flickable.StopAtBounds //禁止列表首尾滑动
maximumFlickVelocity:7000 //设置滑动的最大速度
listView设置headerItem:
header: Rectangle{
width: listView.width
height: 70
color: "green"
Label{
anchors.centerIn: parent
text: "this is header"
}
}
原文链接:(5条消息) QML ListView几个常用且非常重要的属性_luoyayun361的博客-CSDN博客
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了