QML 写界面的时候,把自己坑了,不能正确的选中一行,最后发现第一列用了"index",这个可能是TableView的内置属性(猜测),后边给index赋值,所以不能选中争正确的行,换一个名字即可。
TableView
{
x:320;y:0;width: 700;height: 730;
selectionMode: SelectionMode.SingleSelection;
TableViewColumn{role: qsTr("index");width: 25;horizontalAlignment: Text.AlignHCenter;}
TableViewColumn{role: qsTr("name");title: qsTr("名称");width: 100;horizontalAlignment: Text.AlignHCenter;}
TableViewColumn{role: qsTr("user");title: qsTr("所有者");width: 100;horizontalAlignment: Text.AlignHCenter;}
TableViewColumn{role: qsTr("createdate");title: qsTr("创建日期");width: 100;horizontalAlignment: Text.AlignHCenter;}
TableViewColumn{role: qsTr("audit");title: qsTr("全面审计追踪");width: 100;horizontalAlignment: Text.AlignHCenter;
delegate: Rectangle{anchors.fill: parent;border.color: "#222222";border.width: 1;color: "#d4d0c8";
Check