我正在编写我的应用程序基础代码,并使用pyside开发应用程序。 我唯一的问题就是启动qml开关。 目前我在qml文件中有:
signal buttonClicked;
//function start(){text.text="started";buttonClicked()}
Switch {
id:switchComponent
anchors.verticalCenterarent.verticalCenter;
anchors.horizontalCenterarent.horizontalCenter;
}
//end of switch
Text {
id:text
color:"red"
anchors.bottom: switchComponent.top
anchors.horizontalCenter: switchComponent.horizontalCenter
//text: switchComponent.checked ? "GROUNDWORK ON" & start() : "Press to Start"
//text: switchComponent.checked ? "GROUNDWORK ON" && start() : "Press to Start"
text: switchComponent.checked ? start() : "Press to Start"
font.pixelSize: 30
smooth:true
}
当应用程序启动时,按switchedComponent将信号发送到python,连接到信号的函数将启动,但开关永远不会变为蓝色,文本也不会变为“started”。知道应用程序正在运行的唯一方法是大约10秒后,系统会要求您关闭应用程序。如果你按“否”,那么这个应用程序就可以正常工作了。在
有人知道为什么会这样吗?我基本上只想在python函数开始运行之前激活开关和文本,这样用户就知道发生了什么。 编辑:可以找到完整的qml文件这里.https://projects.developer.nokia项目.com/airplay/browser/groundwork/qml/主.qml我认为这只是将pyside与qml结合使用的一部分,ui线程在处理python函数时会阻塞qml。在
我被你的代码弄糊涂了(开关不见了),所以我只能猜测。
在文本组件中调用start()在我看来是错误的。应该是的
文本不再需要明确设置,开关必须触发组件的信号。
^{pr2}$我只是在猜测你的代码。
相关问题 更多 >
编程相关推荐