TableView关于Activated信号问题
代码如下,却收不到activated信号,不知是怎么回事
Rectangle {
width: 360
height: 360
TableView{
id: phoneTable
anchors.fill: parent
//TableViewColumn 描述表格的每一列
TableViewColumn{role: "name"; title: "Name"; width: 30; elideMode: Text.ElideRight;}
TableViewColumn{role: "cost"; title: "Cost"; width: 100;}
TableViewColumn{role: "manufacture"; title: "Manufacture"; width: 140;}
itemDelegate:Text{//设置每个单元格的字体样式
text: styleData.value
color: styleData.selected? "red" : styleData.textColor
elide: styleData.elideMode
}
headerDelegate :Rectangle{//设置表头的样式
implicitWidth: 10
implicitHeight: 24
gradient: styleData.pressed ? phoneTable.pressG :
(styleData.containsMouse ? phoneTable.hoverG : phoneTable.nomalG)
border.width: 1
border.color: "gray"
Text{
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 4
anchors.right: parent.right
anchors.rightMargin: 4
text: styleData.value
color: styleData.pressed ? "red" : "blue"
font.bold: true
}
}
model: ListModel{
id: phoneModel
ListElement{
name: "rongyao2";
cost: "4900";
manufacture: "huawei"
}
ListElement{
name: "s6";
cost: "4800";
manufacture :"sumsung"
}
ListElement{
name: "apple5"
cost: "3300"
manufacture: "apple"
}
ListElement{
name: "Mi5"
cost: "3200"
manufacture: "xiaomi"
}
}//model is end
focus: true
}
}
Connections{
target: phoneTable;
onActivated: console.log(row); //不触发
}