With the release of Qt 4.7.1 and Qt Mobility 1.1.0, both in 9th Nov 2010, their support for QML has greatly improved. This modest guide will assume that none of these tools are installed in the current system.
The following four items are to be installed:
- MinGW (automated installer)
- Qt 4.7.1 (open source, mingw version)
- Qt Creator pre-2.1 (latest snapshot)
- Qt Mobility 1.1.0 (only sources available)
Once the three first items have been installed, open the Qt 4.7.1 Command Prompt, which should be available via start menu, and change the current directory to Qt Mobility source location.
Start off by running the configuration, you may change the prefix, which in this case assumes that Qt was installed in C:\Qt\4.7.1 directory.
configure.bat -prefix=C:\Qt\Mobility -releaseNext step would be to initiate the compile process:
mingw32-makeInstallation:
mingw32-make installFinally add the library directory to the PATH variable. In this example it would have been C:\Qt\Mobility\lib. This can be done via Control Panel -> System -> Advanced System Settings -> Advanced tab -> Environment Variables. Edit the PATH variable by adding the above library path to the end, separate from previous values with ; .
The Qt Mobility API with QML bindings is filled with opportunities, while the following example merely tests the successful installation.
You should be able to see in the C:\Qt\4.7.1\imports directory few additional folders, each named according to the API parent, such as QtMobility and QtMultimediaKit.
import QtQuick 1.0
import QtMobility.location 1.1
/**
* Map with a simple interaction to change its center
* http://apidocs.meego.com/git-tip/qtmobility/qml-map.html
*/
Rectangle {
width: 800
height: 600
Map {
id: mapArea
anchors.fill: parent
// http://en.wikipedia.org/wiki/Ut%C3%B6,_Finland
center.latitude: 59.783333
center.longitude: 21.366667
connectivityMode: Map.OnlineMode
mapType: Map.TerrainMap
size.width: parent.width
size.height: parent.height
zoomLevel: 14
// No idea where to find a list of possible plugins...
plugin : Plugin {
name : "nokia"
}
MapCircle {
border.color: "pink"
border.width: 2
center: mapArea.center
radius: 1000 // 1 km
}
}
// Change map center to where it was clicked
MouseArea {
anchors.fill: parent
onClicked: {
var pos = mapArea.toCoordinate(
Qt.point(mouse.x, mouse.y));
console.log("alt: " + pos.altitude +
", lat: " + pos.latitude +
", lng: " + pos.longitude);
mapArea.center = pos;
}
}
}Seems actually that the Map element is not "officially" in the release 1.1.0 but in 1.2.0, at least while looking at the documentation version.
Additionally it might be interesting to browse through the bugs for the API. Please post there if you encounter any problems or errors.






















