求解! qml的 Component.onCompleted和 Keys问题

mmic 2017-09-17 09:13:02
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.4

Window {
id:win;
visible: true
width: 640
height: 480
color: "black";

Text {
id: txt;
color: "white";
text: qsTr("My Test Text.");
font{
pointSize: 20;
bold: true;
italic: true;
}

Keys.enabled: false;
Keys.onEscapePressed: console.log("tab... ...");
}

Button{
id: btn;
anchors.top: txt.bottom;
anchors.topMargin: 10;
text: "TestButton";
// Component.onCompleted: {
// btn.clicked.connect(txtQuit());
// }
}

Component.onCompleted: {
btn.clicked.connect(txtQuit());
}

function txtQuit(){
Qt.quit();
}
}

Component.onCompleted: 附加组件里的信号,没有起作用不知道为什么, 麻烦那个前辈解答一下,谢谢
Key 属性也没有起作用,也不起作用,也求解下, 谢谢

Qt 版本 5.8 windows平台 Qt+vs2015编译器
...全文
643 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,199

社区成员

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

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