PDA

View Full Version : dynamic library with Qt4 dialogs in exported functions



Onanymous
9th June 2010, 18:38
I am trying to write a dynamic library to get access to some hardware, and use Qt for dialogs in exported functions.
Now if I try to use it from another Qt application it works more or less (more in linux, less in windows), if I omit QApplication construction, otherwise it complains. On the other hand if I try to use the library from native win application I have to include QApplication calls, and even then it works really strange. And I have not tried it yet with gtk programs. What is the proper way of doing this?

high_flyer
10th June 2010, 09:07
I don't understand:
do you have a Qt application that links to a non Qt lib, or do you have a non Qt application that links to a Qt lib?

Onanymous
10th June 2010, 09:25
I have (or rather want to build) a .dll or .so file which exports functions with qt dialogs. and I want that .so or .dll to be usable by both qt and non-qt-based applications.

high_flyer
10th June 2010, 11:00
Making it usable for non Qt applications is going to be VERY difficult due to the fact that you need the QApplication event loop, which will not allow another event loop (in principal), and I am not sure about how simple it will be to have a lib running QApplication in it.
Almost any other way will probably be easier.
For Qt applications just have a look in the docs about plugins.

Onanymous
10th June 2010, 15:24
Making it usable for non Qt applications is going to be VERY difficult due to the fact that you need the QApplication event loop, which will not allow another event loop (in principal), and I am not sure about how simple it will be to have a lib running QApplication in it.
Almost any other way will probably be easier.
For Qt applications just have a look in the docs about plugins.

what are the other ways?
is there a way to check that my lib was loaded by qt program? The rest can be solved somehow I guess.
So the lib is going to be accessible only by qt applications? sounds a bit microsoftish, or maybe applish, ha? :)

high_flyer
10th June 2010, 17:21
Any other way is rethinking what you really want, and how to achieve it.
If you tell us more about what is the result you are after, we might be able to suggest other ways to achieve it.


So the lib is going to be accessible only by qt applications? sounds a bit microsoftish, or maybe applish, ha?
No, it has nothing to do with that.
For the very least, because Qt is open source, so you can really do anything you like.
Its a matter of merging the event loops.
I didn't say its impossible, just that its very hard - technically, not because Qt wants to dominate the world.

Now lets start again.

I am trying to write a dynamic library to get access to some hardware, and use Qt for dialogs in exported functions.
This is not clear.
Is it a hardware access lib, or a gui lib?
Its a good idea not to mix the two.
Why can't you have your hardware stuff in a lib, (write it in ANCI C/C++ so any one can access it) and write a Qt application for the GUI, that will link against the lib.
This way, any one can write other GUI's, with any other tool kit, on any other platform, but use the same hardware lib.