Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Geolocation and compass data in Qt application

Hi

 

Sorry, more Qt issues...

 

Is there a way to get access to geolocation and compass data within a Qt application? Looking at the NDK docs, it seems that an application has to register for specific events to get this data. There doesn't seem to be any API calls of the form "get_latitude()" or "get_heading()", except those that parse an event.

 

I suppose a more general question is -- Do native platform events come into a Qt application's event loop at all? And, if so, in what form?

 

Best wishes

Kevin

 

Please use plain text.
Developer
borceg
Posts: 671
Registered: ‎03-21-2012
My Device: BlackBerry PlayBook 16GB
My Carrier: Vip

Re: Geolocation and compass data in Qt application

You can use native sdk api for geolocation/gps within Qt app. Just take a look at ndk recipes and import them in your Qt code (in separate Qt thread).

Native Qt location requires Qt mobility, Gps part of it is not working on PB as far as I now.
Please use plain text.
Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Re: Geolocation and compass data in Qt application

Thanks for the reply, but I'm a bit confused...

 

The example you refer to in the Recipes section does bps_get_event() in a loop. If I do that in a separate thread, won't the call to bps_get_event() also consume events that ought to go to the user interface? Or does the Qt implementation get events in a completely different way (ie., not calling bps_get_event())?

 

Sorry if I'm missing something here.

Please use plain text.
Developer
borceg
Posts: 671
Registered: ‎03-21-2012
My Device: BlackBerry PlayBook 16GB
My Carrier: Vip

Re: Geolocation and compass data in Qt application

Well, I assume that it should be background thread (to be honest my experience with threads is not great). As this states "The geolocation_set_period() function sets the period, in seconds, at which geolocation events are reported to the application. If the period is set to 0, a single geolocation event is delivered." So you can set at what priod/time to get the location data.

Bikeator app is written in Qt and it uses location. http://www.bikeator.de/bikeatorqt/en/bikeator/index.html I think that author of it is active on these forums
Please use plain text.
Contributor
mcguire
Posts: 24
Registered: ‎09-10-2012
My Device: Blackberry Dev Alpha
My Carrier: -

Re: Geolocation and compass data in Qt application

For the compass, use QCompass from QtMobility, which is now part of the NDK.

Location API is also part of the NDK, though I don't know the details.

 

About native BPS events: Qt's event loop integrates BPS events, there is no need to create a seperate thread for that.

 

In Qt4, use QAbstractEventDispatcher::setEventFilter() to receive native BPS events. Note that native event filters are chained, setEventFilter() returns the previous one - make sure to pass all events through to the previous event fitler, otherwise Qt itself will miss out important events.

Please use plain text.
Contributor
kboone
Posts: 41
Registered: ‎09-14-2012
My Device: Playbook 64Gb
My Carrier: n/a

Re: Geolocation and compass data in Qt application

OK, thanks. I will look into that approach.

Please use plain text.