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 p开发者_Go百科ython functions.
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
Text {
...
text: switchComponent.checked ? "GROUNDWORK ON" : "Press to Start"
}
The text doesn't have to be set explicitely anymore and the switch has to trigger the signal of your component.
Switch {
onCheckedChanged: {
if (checked) {
buttonClicked()
}
}
}
This is just guessing with my understanding of your code.
精彩评论