各位高手,请教一下:
下面QML创建了一个TableView,想实列表过滤功能,在表头中加入了一个TextField控件,但发现无法点击进去编辑,感觉是TableView在列表头上做了什么,完成没有将点击传下去给TextField。
Item {
anchors.fill: parent
ListModel {
id: datas
ListElement {workid: "1234567"; engineer: "aaaa"; }
ListElement {workid: "123"; engineer: "bbbbb"}
}
TableView {
id: workTable
anchors.fill: parent
model: datas
TableViewColumn {width: 80; movable: false; role: "workid"; title: qsTr("ID")}
TableViewColumn {width: 80; movable: false; role: "engineer"; title: qsTr("Test")}
headerDelegate: Rectangle {
height: 50
RowLayout {
anchors.fill: parent
Item {
Layout.fillWidth: false
Layout.minimumWidth: 0.5
Layout.preferredWidth: 0.5
Layout.maximumWidth: 0.5
height: 1
}
ColumnLayout {
Layout.fillWidth: true
Text {
Layout.fillWidth: true
Layout.fillHeight: false
Layout.maximumHeight: 25
Layout.minimumHeight: 25
Layout.preferredHeight: 25
verticalAlignment: Text.AlignBottom
elide: Text.ElideRight
font.bold: true
text: styleData.value
}
Item {
Layout.fillWidth: true
Layout.fillHeight: false
width: parent.width
Layout.maximumHeight: 20
Layout.minimumHeight: 20
Layout.preferredHeight: 20
Row {
anchors.fill: parent
TextField {
width: parent.width - 18
height: parent.height-2
font.pixelSize: 12
menu: null
}
Item {
width: 18
height: parent.height
}
}
}
}
Item {
Layout.fillWidth: false
Layout.minimumWidth: 0.5
Layout.preferredWidth: 0.5
Layout.maximumWidth: 0.5
height: parent.height
Rectangle {
width: parent.width
height: parent.height-10
anchors.centerIn: parent
radius: 3
color: "#94C668"
}
}
}
}
}
}