qt - 如何在 ListView 的项目之间设置自定义分隔符

标签 qt qml qt5 qtquick2

有没有办法使用自定义委托(delegate)作为 ListView 的每两个连续项目之间的分隔符就像 headerfooter特性?

最佳答案

一个 ListView可分为sections ,又称组。该文档提供了一个很好的示例 here .

基本上你定义一个 Component ,就像您为 Header 所做的那样和 Footer , 并将其设置在 section.delegate子属性。在代码中:

列表显示 {
编号:查看
[...]

    section.property: "size"                    // <--- the splitting property name
    section.criteria: ViewSection.FullString    // <--- specify the way section is created (see the provided link)
    section.delegate: sectionDelegate           // <--- your delegate
}

关于qt - 如何在 ListView 的项目之间设置自定义分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27034972/

相关文章:

qt - 如何在 qml 中触发显式 UI 更新?

python - 在用 python 问题编写的 qt 应用程序中缩放嵌入式 matplotlib 小部件

C++/Qt QDomDocument : iterate over all XML Tags

c++ - 在层次结构深处访问 QML 信号

c++ - 在 Qt QML 中为许多文本元素指定字体

c++ - Qt5 用户界面编译器 : -i option not available

c++ - 你能把QWidgets放到栈上吗?

c++ - 在 QTextEdit 中使用富文本

javascript - 获取对 QML 中动态创建的 ChartView 的引用

qt - qmake:使用定义作为条件