1

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.

1 Answers1

0

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.

blakharaz
  • 2,580
  • 13
  • 18
  • What you are saying makes sense and I tried to do it your way but I get the same results. The program works but no response from the Gui. I think the main gui thread for qml is blocked waiting for the python task to complete. I think I will have to put a dummy task in between my main task and the switch being pushed. Anyway now I know how to check status and state withing a button so thanks for that. – thegreattaurus Sep 08 '11 at 15:17