maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   Maemo 5 APIs with Qt (https://talk.maemo.org/showthread.php?t=33657)

kdrozd 2009-10-29 10:24

Maemo 5 APIs with Qt
 
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 2009-10-29 10:36

Re: Maemo 5 APIs with Qt
 
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]

yerga 2009-10-29 11:21

Re: Maemo 5 APIs with Qt
 
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).

w00t 2009-10-29 11:29

Re: Maemo 5 APIs with Qt
 
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...

javispedro 2009-10-29 11:32

Re: Maemo 5 APIs with Qt
 
Quote:

Originally Posted by w00t (Post 360582)
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 2009-10-29 11:47

Re: Maemo 5 APIs with Qt
 
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()

lefa 2010-01-12 13:45

Re: Maemo 5 APIs with Qt
 
Quote:

Originally Posted by kdrozd (Post 360575)
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?

folnin 2010-01-12 14:03

Re: Maemo 5 APIs with Qt
 
Quote:

Originally Posted by kdrozd (Post 360575)
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.

rlinfati 2010-01-12 14:11

Re: Maemo 5 APIs with Qt
 
look https://garage.maemo.org/plugins/ggi...atitude;a=tree

QT + liblocation

folnin 2010-01-12 15:07

Re: Maemo 5 APIs with Qt
 
Quote:

Originally Posted by rlinfati (Post 466342)

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 :D).

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.


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

vBulletin® Version 3.8.8