【发布时间】:2023-03-12 05:12:01
【问题描述】:
我想在TableView 中为代表Component 创建一个ToolTip。它工作正常,如果我使用ItemDelegate,但是,我不能使用ItemDelegate,因为它破坏了TableView 的选择模式。如果我尝试在我的委托组件中定义ToolTip,我会收到错误
qrc:/FileSystem.qml:34 Invalid component body specification
如何为Component 使用工具提示?
这是我的代码:
TreeView {
id: view
anchors.fill: parent
sortIndicatorVisible: true
model: fileSystemModel
rootIndex: rootPathIndex
selection: sel
selectionMode: 2
Component {
id: mycomp
Row{
id: myrow
CheckBox{
id: cbox
anchors.baseline: ctext.baseline
}
Text{
id: ctext
text: styleData.value
color: styleData.textColor
width: namecolumn.width-cbox.width-myrow.x
elide: Text.ElideRight
}
}
NC.ToolTip {
parent: mycomp
visible: hovered
delay: 1000
text: qsTr(styleData.value)
}
}
TableViewColumn {
id: namecolumn
title: "Name"
role: "fileName"
resizable: true
width: parent.width-sizeWidth-dateWidth-scrollBarWidth
delegate: mycomp
}
【问题讨论】: