qt - 自定义 TableViewColumn 委托问题
问题描述
我的自定义委托有几个问题TableViewColumn
。这是我的TreeView:
TreeView {
id: view
anchors.fill: parent
sortIndicatorVisible: true
model: fileSystemModel
rootIndex: rootPathIndex
selection: sel
selectionMode: 2
TableViewColumn {
id: namecolumn
title: "Name"
role: "fileName"
resizable: true
width: parent.width-sizeWidth-dateWidth-scrollBarWidth
delegate: ItemDelegate {
id: fileCheckDelegate
Row{
CheckBox{
id: cbox
visible: (model.isDir==true) ? false : true
}
Text{
id: itext
text: model.fileName
width: namecolumn.width-itext.x-cbox.width
elide: Text.ElideRight
}
}
ToolTip {
parent: fileCheckDelegate
visible: hovered
delay: 1000
text: qsTr(model.fileName)
}
}
}
TableViewColumn {
id: sizecolumn
title: "Size"
role: "size"
resizable: false
width: sizeWidth
}
TableViewColumn {
id: datecolumn
title: "Date Modified"
role: "lastModified"
width: dateWidth
resizable: false
}
}
问题如下图所示:
- 文件名不会被截断,尽管我认为自定义委托应该计算宽度,以便 elide 添加省略号。我的计算有什么问题?
- CheckBox 没有垂直居中,如何实现呢?编辑:评论中的解决方案足够好
- 我的自定义委托没有交替的背景颜色。我怎样才能做到这一点?
- 此外,如果选择了一个项目,我的自定义委托没有突出显示颜色。这特别奇怪,因为当我在 Qt TableView 示例中使用我的委托时,委托也接收到高亮颜色。这可能与我混合 Controls 1.4 和 2.4 有关吗?
谢谢你的帮助,
解决方案
推荐阅读
- excel - 在表格的新列中使用公式
- sqlite - Dill TypeError:无法腌制“sqlite3.Connection”对象。函数中的任何地方都没有 Sqlite
- atata - AutoSetUpConfiguredDrivers 偶尔会抛出“索引超出范围”异常
- python - 使用 pycharm 的 Python 程序未在 sublime 文本上运行
- asp.net - 从 SVG 点击调用 asp
- api - API 调用的属性约束:在模式或业务逻辑中捕获?
- r - 为什么我在使用闪亮的应用程序时得到无效的“宽度”或“高度”?
- php - 用于在 PHP cURL 中输出数组的 For 循环
- android - 定位 R+(版本 30 及更高版本)要求已安装 APK 的 resources.arsc 未压缩存储并在 4 字节边界上对齐
- stream - 对 webm 流的请求忽略范围标头