TableView关于Activated信号问题

yayafu 2019-01-30 10:12:44
代码如下,却收不到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); //不触发
}
...全文
1182 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yayafu 2019-02-12
  • 打赏
  • 举报
回复
有哪位大侠知道吗?

16,173

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧