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

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

问题描述:

有没有办法像 headerfooter 属性一样使用自定义委托作为 ListView 的每两个连续项之间的分隔符?

Is there a way to use custom delegate as a separator between every two consecutive items of ListView just like header and footer properties?

ListView 可以分为 sections,也就是组.该文档提供了一个很好的示例此处.

A ListView can be divided in sections, aka groups. The documentation provides a nice example here.

基本上你定义一个 Component,就像你为 HeaderFooter 所做的一样,并在 section.delegate 中设置它 子属性.在代码中:

Basically you define a Component, much like you do for Header and Footer, and set it in the section.delegate subproperty. In code:

列表视图{编号:查看[...]

ListView { id: view [...]

    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
}