PDA

View Full Version : qt creator qt components quickstart example doest work for me



krishmav
2nd September 2011, 18:50
Hi,

I am new to QML. I was testing the quickstart example in Qt creator 2.3 titled "Creating a Qt Quick Application Using Qt Quick Components", but the progressbar doesnt change when battery level changes in Qt Simulator. Progressbar shows correct value initially, but doesnt reflect the changes according to battery level. I think i am not able to set up the signal properly. Here is the online link to the example : http://doc.qt.nokia.com/qtcreator-snapshot/creator-qml-components-example.html.
Can anyone help me solve the problem.

krish

tipul07
5th September 2011, 11:56
Yes... This is not a good example to start with...

I decided too to switch from "classic" widgets to Qt Quick (so kindda newbie here). But as Qt Quick is in big/rapid development there are changes/breaks into code/documentation between QtMobility 1.1 and QtMobility 1.2 (at least in documentation and it seems in libraries as code doesn't work)...

QtMobility 1.2 example:
http://doc.qt.nokia.com/qtmobility-1.2/qml-deviceinfo.html#details

QtMobility 1.1 example:
http://doc.qt.nokia.com/qtmobility-1.1/qml-deviceinfo.html#details

So in 1.1 to tell system to send signals to your app you should use start* methods:


Detailed Description

This element is part of the QtMobility.systeminfo 1.1 module. It is a convience class to make QML usage easier.

Note: To use notification signals, you need to use the start* slots.

Component.onCompleted: {
deviceinfo.startPowerStateChanged();
deviceinfo.startBatteryLevelChanged();
}


But in 1.2, you should use monitor* methods:



Detailed Description

This element is part of the QtMobility.systeminfo 1.1 module. It is a convience class to make QML usage easier.

Note: To use notification signals, you need to set the monitor* properties to true.


Even if it's said in docs that:



monitorBatteryLevelChanges : bool read-only

Use the monitorBatteryLevelChanges signal.


monitorBatteryLevelChanges is a read-only property it can really be assigned a bool value. So in order to fix the example you should change:


Component.onCompleted: {
//deviceinfo.startBatteryLevelChanged();
deviceinfo.monitorBatteryLevelChanges = true;
}