PDA

View Full Version : Can I create a QApplication inside a DLL?



oob2
7th June 2006, 01:22
Hi,

I have a program which is an app with QApplication. Can I just change the project file to make it a DLL (instead of EXE), and remove the main function and still keep my original QApplication?


Thanks.

fullmetalcoder
7th June 2006, 11:57
Sure you can but you'll still need an executable linked to the shared library or your program won't launch...

oob2
7th June 2006, 22:04
Hi,

I plan to write a DLL which contains a QApplication with a lot of gui(s) (It used to be a EXE, now I want to make it a DLL). And my customer will write another Qt EXE which also contains a QApplication with their gui(s). This EXE then link against my DLL.

Is it possible?

Thanks

wysota
8th June 2006, 00:22
I don't think it's a good choice... Maybe it's better not to create a QApplication inside the dll and just use the one provided by the main binary? This would be the "usual" way to do it. Otherwise you'd have to implement those GUIs as a separate thread (you can't have two QApplication objects in the same thread, or even the same application -- you have to use QThread::exec instead).

You should read about extending Qt applcations with plugins . Maybe the concept will become more clear then... and maybe that's what you really want.

Elder Orb
30th June 2006, 12:58
What if I need to create a dll which could be used from win api, mfc and Qt applications. In such a case I need QApplication inside dll for mfc/win api programs, but don't need for Qt-based apps. Is it possible to find from dll if application Qt-based or not ?

fullmetalcoder
1st July 2006, 08:42
why would you need to mix Qt and MFC/WinAPI ??? Are you sure you're working on the best design??? Your approach seems an overkill and AFAIK the only way to check if a dll uses Qt is to doit on your own by creating an exported function/variable and looking for it in the exported symbols of the dll... And that is an suicide as well!

Elder Orb
1st July 2006, 10:08
It's not my decision to mix Qt and mfc. I simply have to do it. :) Anyway the problem was solved. I've exported function "init()" which must be called before dll using.