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博客

posted @   Azuki_op  阅读(340)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示