我正在编写我的应用程序 Groundwork 并且我正在使用 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并且连接到信号的函数启动但开关永远不会变成蓝色并且文本不会变为“已启动”。您知道应用程序正在运行的唯一方法是大约 10 秒后系统会要求您关闭应用程序。如果您按否,则该应用程序将正常工作。
有谁知道为什么会这样?我基本上只是希望在 python 函数开始运行之前激活开关和文本,以便用户知道发生了什么。编辑:完整的 qml 文件可以在这里找到。 https://projects.developer.nokia.com/airplay/browser/groundwork/qml/main.qml 我认为这只是将 pyside 与 qml 一起使用的一部分,即 ui 线程处理python函数时阻塞。