PDA

View Full Version : creating Qt libraries



stefano_p
11th September 2006, 16: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!

Stefano

jacek
11th September 2006, 16: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.

stefano_p
11th September 2006, 17:08
Mmmmmh.
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.....

Stefano

wysota
11th September 2006, 17: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.

stefano_p
11th September 2006, 17:28
Uhm....
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....

Bye,

Stefano

wysota
11th September 2006, 18:53
Uhm....
you mean connecting to the base application by use of an istance of the QProcess class?
Yes.


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

Brandybuck
12th September 2006, 00: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.