多行文本项未在 QML 列表视图中剪裁



我有一个QML页面,其中包含包含页面标题,ListView和关闭按钮的GridLayout:

GridLayout {
columns: 1
rows: 5
anchors.fill: parent
<page title item>....
ListView
{
spacing: 15
model: logModel
delegate: Item {
implicitWidth: parent.width
implicitHeight: grid.height
RowLayout
{
id: grid
spacing: 0
width: parent.width
height: commentLabel.implicitHeight
<icon>....
Label {
id: commentLabel
Layout.fillWidth: true
text: comment
wrapMode: Label.Wrap
}
}
}
ScrollIndicator.vertical: ScrollIndicator { }
}
<close button>...
}

当我滚动列表时,列表中的第一个和最后一个可见项目可能会超出列表 bounder 并与页面标题或关闭按钮相交:

如何防止这种情况并使项目被剪裁?

编辑1:

我试图添加

clip: true

到列表视图,委托项目,行布局和标签,但没有成功。根据文档,将剪辑属性设置为 true 的 ListView 应该剪辑其内容,不是吗?

我发现了一个类似的问题,其中剪辑属性是答案,但不清楚为什么它不适用于我的 ListView。

我的 QT 版本是 5.13.2。

ListView组件中设置clip:true

ListView
{
clip:true
}

最新更新