View Full Version : creating Qt libraries

11th September 2006, 15:30
Hi to all,
I' like to know your advice on the following topic:
Would it be possible to compile a Qt based application as a library, and then importing and using it from a C program?

I've seen that there are several ways for performing the inverse operation (using C code in Qt/C++ programs), but only little documentation on this topic.

I've seen the QtC RPMs, for using Qt into C programs, but I'm using an embedded
version of qt, with a lot of custom widget, and I have to solve it VERY shortly.

Any help will be very wellcome.

Best regards to everyone!


11th September 2006, 15:37
Qt needs a running event loop. You could try to invoke a library function that creates QApplication instance and starts the event loop, but it won't return until you stop the Qt part of your program.

11th September 2006, 16:08
Sounds quite tricky.

I explain better the situation.
I have an application, written entirely in C language. It must continuosly visualize on a screen the variation of a parameter. The 'graphical' part of the app must be Qt based. So I need to start the Qt program from the C one and continuosly pass to it values to be displayed.

If I understand well your answer, it could be possible at least start the Qt part of the program, with its event loop, but then the c program would lay until the Qt runs, isn't it?

Maybe I could propose the reverse solution, the 'leading' aplication written in C++ and the C code inserted inside with, let's say, the "extern 'C'" keyword....

Of course I'm always open for simpler (and faster) solutions.....
However, Thank you very much.....


11th September 2006, 16:22
Maybe it could be easier to incorporate the C application into the Qt-based GUI as a separate thread? Alternatively you can connect to the base app's stdin and stdout and communicate with it from a separate (GUI) process.

11th September 2006, 16:28
you mean connecting to the base application by use of an istance of the QProcess class?

This sound veeery nice.....

Ok, thanks a lot.
I will update you with the progresses, if any....



11th September 2006, 17:53
you mean connecting to the base application by use of an istance of the QProcess class?

This sound veeery nice.....
Yes, if the base application allows controlling it through stdin/stdout.

11th September 2006, 23:27
Sounds like a job for IPC. If you're using X11, then Qt 4.2 has dbus for a good IPC mechanism. Otherwise you'll need to roll your own, possibly using QProcess.