[SailfishDevel] How to get GPS Location in QML

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Tue Oct 29 19:09:22 UTC 2013


Hi Bolek

In my last post I hinted that my example yaml / spectacle file worked,  
but was not perfect.

This evening on the train I was able to experiment further. I am now  
home, with a roast chicken bubbling in the oven, and a glass of cold  
white Rioja next to me, so I have time to post the results (but the  
chicken will need turning soon ...)

My example app is the default Sailfish app, with a PositionSource  
element added to the FirstPage.qml as below:

import QtPositioning 5.0

Page {
     id: page

     Component.onCompleted: positionSource.start()

     PositionSource {
         id: positionSource

     }
	?.other stuff here
}

I then changed entries in the PkgConfigBR and PkgBR sections. Between  
each test I used the SDK Control Center to remove all Positioning  
packages from the SDK, and synced with Qt Creator. Also after each  
build I repeated the sync.

These are the tests and the results:

1) No positioning entries in PkgConfigBR or PkgBR (QML only project)
Code compiles and runs without error, but Qt Creator QML does not  
recognise import or components

--> QML Positioning development possible but painful, C++ not possible.

2) Positioning entry in PkgBR only
qt5-qtdeclarative-import-positioning

This actually installs the following 2 packages:
qt5-qtpositioning-5.1.0+git10-1.7.1.i486.rpm
qt5-qtdeclarative-import-positioning-5.1.0+git10-1.7.1.i486.rpm

After build, and SDK Control Center sync (and Qt Creator  
Tools/QML/Reset Code Model), Qt Creator QML now recognises import  
statement and Positioning Components (now coloured purple).

--> Good for QML Positioning development, not ok for C++.

3) Positioning entry in PkgConfigBR only:
Qt5Positioning

This actually installs the following 2 packages:
qt5-qtpositioning-5.1.0+git10-1.7.1.i486.rpm
qt5-qtpositioning-devel-5.1.0+git10-1.7.1.i486.rpm

Code compiles and runs without error, but Qt Creator QML does not  
recognise import or Positioning components (as in case 1) above).

4) 2 Positioning entries in PkgBR, no Positioning Entry in PKConfigBR
qt5-qtdeclarative-import-positioning
qt5-qtpositioning-devel

This actually installs the following 3 packages
qt5-qtpositioning-5.1.0+git10-1.7.1.i486
qt5-qtdeclarative-import-positioning-5.1.0+git10-1.7.1.i486
qt5-qtpositioning-devel-5.1.0+git10-1.7.1.i486.rpm

After build, and SDK Control Center sync (and Qt Creator  
Tools/QML/Reset Code Model, Qt Creator QML now recognises import  
statement, and Positioning Components.

--> Good for both QML and C++ Positioning development

Conclusion:
The config of test 2) above is good for QML only development with Positioning.
The config of test 3) above is good for C++ Positioning development only.
The config of test 4) above is good for both QML and C++ Positioning  
development.

Later I will experiment with the yaml Requires: section (for the  
Emulator), and post the results.

I hope this helps

Chris




Zitat von tw_bolek <tw_bolek at op.pl>:

> Hi Chris,
>
>>> So the import we need is Import QtPositioning 5.0
>
> Unfortunately, "QtPositioning 5.0" gives "QML module not found" and  
> it is underlined in red in QtCreator...  Adding QT += positioning   
> to the .pro file does not change anything.    There is no trace of  
> "QtPositioning" in sailfishos/mersdk/targets/.../usr/lib/qt5,   
> neither for arm nor for x86 (emulator).
>
> Bolek
> _______________________________________________
> SailfishOS.org Devel mailing list
>





More information about the Devel mailing list