GLib based event dispatcher: how to compile it from QT Everywhere source code?
-
Hi,
I'd like to use some Glib based event dispatcher to mix QT and GLib based libraries.
I've been looking into QT (Everywhere) source code and found out there is a QEventDispatcherGlib class available.
Problem is I wasn't the one who compiled QT for my embedded platform. I just got it from the platform makers.Is there any way to compile this class code outside QT? Compile with my applications code (for instance) or something like that?
In worst case, would it be too difficult to compile the entire QT myself?
Thanks very much.
-
Compiling Qt manually is not very difficult in general. It may be getting complicated when cross compiling though, you need to setup the complete environment for the target, have all the libs around etc. To add glib support you should call the configure script with -glib.
-
I realize that the environment is mandatory. I'm working on an embedded solution for that platform.
My focus in on the following files (relative to qt-everywhere-opensource-src-4.6.0):./src/corelib/kernel/qeventdispatcher_glib_p.h
./src/gui/kernel/qguieventdispatcher_glib.cppIf you check them, there is a note that says:
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of the QLibrary class. This header file may change from
// version to version without notice, or even be removed.
//
// We mean it.
//I'm wondering how can I use this class inside my application or take advantage of this class while running my application.
That seems to allow me to integrate GLib based libraries (the old GMainLoop issue) with QT.Do you have any idea on how to do that?
Thanks very much for answering (specially this fast).
-
You can grab the two files, rename the files and the classes inside it and use them for your own purpose. That's what we've done a few times with some other helper classes, which are private to Qt. Be aware of some license issues, though (provide the sources in case of (L)GPL).
-
IIRC Qt uses a glib based eventloop by default, at least on Linux. Mixing glib and Qt based code in one application is possible by default AFAIR.
So I do not understand your question:-)
Please be aware of the license implications when copying code from Qt into your libraries: LGPL does only apply when doing dynamic linking, so it is not an option when copying code over into your project.
-
Volker,
I intend to grab those 2 files and do so, preserving the license restrictions and anything else.
However those files have references to lots of other files from the QT source code.
I believe I'm going to have trouble to compile this code by myself because QT Makefiles use a lot of pre-processor definitions (-D) and this kind of stuff (configure script and related).
I thought there would be a better way to do that.Tobias,
I'll have a look at IIRC. Thanks for the suggestion.
I'm having trouble to find information regarding QT embedded details (event loop details, for instance).
Do you know whether GLib based event loop is default in Embedded QT (QWS and non QWS) or not?
Don't worry about lincense issues. I'll preserve that.Thanks very much for both of you.
-
http://labs.qt.nokia.com/2006/02/24/qt-and-glib/ is the first hit on google for Qt and glib.
-
Tobias, I know that.
That was my start point on this issue. Unfortunely, it doesn't say how to do that.
I tried to find some literature that explains how to implement a QAbstractEventDispatcher, but I couldn't find some.
I tried to check the QT source code for the default Event Dispatcher... it might give some clue on how to do that, that was how I found the files I mentined above.
The problem is that those files seems to have a lot of dependencies in the QT source code and I'm having trouble to understand how to deal with them.
Do you know where can I find something to help me out?Thanks very much.
-
I do not understand your problem then.
As far as I know (but I am no expert in this area) Qt uses the glib event loop by default. So why do you need to write a event dispatcher yourself?
The files you reference are internal to Qt. That is what the warning says: Do not use this, we will change it whenever we need to. We make no guarantees about any of the APIs implemented in those files. So if you decide to use those files anyway, your application may break on the next upgrade of Qt.
That does not say that the APIs are not used internally inside Qt. In fact that event dispatcher should be the one used in Qt on Linux. But again: I am no expert in this area, so I might be wrong.
-
Tobias,
I have contacted the platform development team asking for a recompiled version of the Embedded QT libs with glib support. I believe the -glib configuration option does the magic (uses that dispatcher as the default one).
It is really hard to find information regarding this kind of stuff.
Maybe the the developers of the platform I'm using have some support directly from QT Team on that.
This is what makes me a little more confident about it.Right now, this is absolutely necessary to make my project possible.
I'll post here any proggress on this issue.
Thanks very much.
-
Looks like my QT libs are already compiled with GLib support (the -glib option is default).
I though QT would run a GLib based (GMainContext + GMainLoop) Event Dispatcher when Glib support is enabled. But it doesn't seem to be true. If the GMainLoop was running, my DBus communication would be ok, and it is not.
Now I have no clue what exactly means GLib support for QT.
-
Perhaps you can ask around on IRC. On the freenode network, you can use the #qt channel. If you don't get anything useful there, you might want to ask and see if you can get answer on the #qt-labs channel. Lots of Qt devs hang out there, but it is not geared towards helping end users. Still, if you come up with an interesting question and you could not get that answered elsewhere, you might get lucky. First try in #qt though!
-
Thanks very much Andre. I'll try it!
-
Hi Allan,
After a lot of trying, I gave up using the QT GLib based event loop.
I end up writing my own solution to replace the Glib based library I was using before.
I was using DBus and wrote a custom IPC system based on sockets. It works really well, BTW.Even though, I'm really interested in learning how to use the GLib based loop.
If you manage to do that, please post your solution here. It would be useful to all other users too.Thanks.
-
Don't worry.
If you managed to do that, someone else may find that useful!
I've already found other ways! :D
Thanks!