qt - 为什么在 QML TableView 的 syncView 上设置implicitHeight 会大大降低其性能?
问题描述
我想创建一个简单TableView
的使用另一个来使用属性TableView
显示其标题。syncView
我将标题布局在列中的主要内容上方:
import QtQuick 2.14
import QtQuick.Window 2.12
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import Qt.labs.qmlmodels 1.0
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
ColumnLayout {
anchors.fill: parent
TableView {
Layout.fillWidth: true
id: headerView
implicitHeight: contentHeight //comment this line out and it'll be much faster
model: TableModel {
TableModelColumn {display: "index"}
rows: [{index: "index"}]
}
delegate: Label {
text: model.display
}
}
TableView {
Layout.fillWidth: true
Layout.fillHeight: true
syncView: headerView
syncDirection: Qt.Horizontal
model: TableModel {
TableModelColumn {display: "index"}
rows: Array(100000).fill().map((_, index) => ({index}))
}
delegate: Label {
text: model.display
}
ScrollBar.vertical: ScrollBar {}
}
}
}
不幸的是,设置非零值implicitHeight
会headerView
导致性能变慢。这可以通过快速上下拖动垂直滚动条来感受。这里发生了什么?我使用syncView
错误的方式吗?
解决方案
推荐阅读
- html - 面临“request.POST.get()”方法的问题,它没有获取正确的数据
- javascript - django使用ajax调用后端有问题
- android - 如何使用 Volley 发送 base 64 字符串
- ios - SwiftUI:主从视图中的 SafariView
- java - 为什么当我在eclipse中的spring boot项目中执行主类时出现这个错误“找不到或加载主类”
- templates - 根据某种状态从文档生成中过滤掉图表
- r - 删除数据表中的行 - 闪亮
- javascript - 如何在没有 global.css 文件的情况下覆盖 next.Js 中的材料 ui 类?
- google-analytics-4 - GA4 on Web 事件和渠道问题
- sql - Q 表示法不适用于 oracle 12c 中的变量