Active Topics

 


Reply
Thread Tools
Posts: 54 | Thanked: 40 times | Joined on Aug 2009 @ Wrocław / Poland
#1
How can I use glib libs like liblocation from Qt app?
I want to write applications using the liblocation using Qt.But I do not know how it will work with the GLib to Qt type casting.
 
w00t's Avatar
Posts: 1,055 | Thanked: 4,107 times | Joined on Oct 2009 @ Norway
#2
You can't directly convert GLib and Qt types. You would need to convert a GString to a char pointer, and pass it to QString's constructor, for example, but as far as I know there's also no easy way to do this via GTK's API (other than g_string_free(), which looks dangerous and inefficient for these purposes), so you'd have to go digging in GString's struct for the right member.

[edit: this was just an example, not an exhaustive tutorial]
__________________
i'm a Qt expert and former Jolla sailor (forever sailing, in spirit).
if you like, read more about me.
if you find me entertaining, or useful, thank me. if you don't, then tell me why.
 
yerga's Avatar
Posts: 696 | Thanked: 1,012 times | Joined on Mar 2006 @ Asturies, Spain
#3
Check the PDF in this page: http://wiki.forum.nokia.com/index.ph...velopers_Guide

Chapter 5.1: Using Maemo APIs in Qt applications - Liblocation
The example that comes there is with Gtk though (weird thing being Qt documentation).
__________________
Daniel Martín Yerga
maemo.org profile
Twitter
 

The Following 5 Users Say Thank You to yerga For This Useful Post:
w00t's Avatar
Posts: 1,055 | Thanked: 4,107 times | Joined on Oct 2009 @ Norway
#4
This looks useful, though I'm a bit confused why they've written a Gtk example application using liblocation in a "Qt for Maemo" howto.

Seems kind of strange...
__________________
i'm a Qt expert and former Jolla sailor (forever sailing, in spirit).
if you like, read more about me.
if you find me entertaining, or useful, thank me. if you don't, then tell me why.
 
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#5
Originally Posted by w00t View Post
You can't directly convert GLib and Qt types. You would need to convert a GString to a char pointer, and pass it to QString's constructor, for example, but as far as I know there's also no easy way to do this via GTK's API (other than g_string_free(), which looks dangerous and inefficient for these purposes), so you'd have to go digging in GString's struct for the right member.]
Fortunately, "GLib-like APIs" (how I call Gtk+, liblocation, etc.) tend to favor bare gchar * arrays instead of GStrings. (Can't say the same about Qt libs ).
 
w00t's Avatar
Posts: 1,055 | Thanked: 4,107 times | Joined on Oct 2009 @ Norway
#6
I'm not sure what you mean.

If you mean that Qt doesn't store/accept scalar types, well, they do in a lot of places (or indirectly, via e.g. QString constructor overloads), and it is also possible to extract those types using things like QString::toLatin1()
__________________
i'm a Qt expert and former Jolla sailor (forever sailing, in spirit).
if you like, read more about me.
if you find me entertaining, or useful, thank me. if you don't, then tell me why.
 
Posts: 6 | Thanked: 6 times | Joined on Dec 2009 @ Oulu, Finland
#7
Originally Posted by kdrozd View Post
How can I use glib libs like liblocation from Qt app?
I want to write applications using the liblocation using Qt.But I do not know how it will work with the GLib to Qt type casting.
I have the same problem. I'm trying to develop GPS application for N900. How can i read internal GPS? Is it possible to use liblocation API at all? Has anyone figured out this yet?
 
Posts: 5 | Thanked: 0 times | Joined on Dec 2009
#8
Originally Posted by kdrozd View Post
How can I use glib libs like liblocation from Qt app?
I have very similar problem. However not with the casting.

My Qt application run qt events loop and it seems that for liblocation to work properly it needs a running gtk events loop.

If I use liblocation without gtk events loop started the location_gpsd_control_start function never returns. And callbacks are never called.

Is there somework around to this?

Writting pure gtk application works fine (Using Location API).

Please correct me if I am missing something very obvious.
 
Posts: 177 | Thanked: 199 times | Joined on Nov 2007 @ Concepcion, Chile
#9
look https://garage.maemo.org/plugins/ggi...atitude;a=tree

QT + liblocation
__________________
User:rlinfati
 

The Following 3 Users Say Thank You to rlinfati For This Useful Post:
Posts: 5 | Thanked: 0 times | Joined on Dec 2009
#10
Originally Posted by rlinfati View Post
look https://garage.maemo.org/plugins/ggi...atitude;a=tree

QT + liblocation
Thanks for reply but thats exactly where I have been looking for the past few days.

I have grep'ed your code for g_ (glib function) several times and it seems you don't start any gtk event loops (I have read you code from begginging to and few times also ).

As far as I understand you just register "changed" callback. And call location_gpsd_control_start on the button click event.

In my application the location_gpsd_control_start function call is triggered by http request finished event.

The only difference I see between yours and mine applications is that yours uses GUI. Is there any special trick that you do for liblocation to work?

I think I am missing something really obvious.
Any help would be really appreciated.
I am sorry to bother you, but would it be possible to discuss it with you via IM?

P.S.
I have written you an email with a bit longer description of my problem.
 
Reply

Tags
glib, qtlib


 
Forum Jump


All times are GMT. The time now is 00:01.