qml pyside 和开关
我正在对我的应用程序 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,并且连接到信号的函数启动,但开关永远不会变成蓝色,并且文本不会更改为“started”。您知道应用程序正在运行的唯一方法是大约 10 秒后,系统会要求您关闭应用程序。如果您按“否”,那么该应用程序将正常工作。
有谁知道为什么会发生这种情况?我基本上只是希望在 python 函数开始运行之前激活开关和文本,以便用户知道发生了什么。 编辑:完整的qml文件可以在这里找到。 https://projects.developer.nokia.com/airplay/browser/groundwork/qml/main.qml 我认为这只是将pyside与qml一起使用的一部分,ui线程处理 python 函数时阻塞。
I am coding my application Groundwork and I am using pyside to develop the application.
The only hiccup I am having is getting the qml switch to activate.
Currently I have in the qml file:
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
}
When the application starts, pressing the switchedComponent sends the signal to python and the function connected to the signal starts but the switch never turns blue and the text does not change to "started". The only way you know the application is running is that after ~10 seconds they system will ask you to close the application. If you press NO then the app will work just fine.
Does anyone know why this happens? I basically just want the switch and text to activate before the python function starts running so the user knows whats happening.
Edit: The full qml file can be found here.https://projects.developer.nokia.com/airplay/browser/groundwork/qml/main.qml I think this is just a part of using pyside with qml that the ui thread block when processing python functions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对你的代码有点困惑(并且开关丢失了)所以我只能猜测。
在我看来,在 Text 组件中调用 start() 是错误的。它应该只是
文本不必再明确设置,并且开关必须触发组件的信号。
这只是我对你的代码的理解的猜测。
I'm a little bit confused by your code (and the Switch is missing) so I can only guess.
Calling start() in the Text component seems wrong to me. It should only be
The text doesn't have to be set explicitely anymore and the switch has to trigger the signal of your component.
This is just guessing with my understanding of your code.