PDA

View Full Version : how to use qApp inside a dll?



oob2
21st June 2006, 22:04
Hi,

I have a QT application with a lot of QT widgets. I implement my own MyApplication which inherits from QApplication. In there, I override winEventFilter(). Also, I have some installTranslator code in there.

The main reason I override winEventFilter() is because I'd like to catch win32 Ctrl+F4 key event.

My question is if I'd like to convert my application into a DLL, it means I will not have my own MyApplication, how can I catch Ctrl+F4 event before microsoft close my hwnd? And, how do I install my own translation files? Then I'll handle my DLL to my co-workers because he is going to implement a QT application which will then link against my DLL? Can he pass his qApp to my DLL?

And, where should I put my initialization code (used to be in main()) in a DLL?


Thanks

jacek
23rd June 2006, 22:15
The main reason I override winEventFilter() is because I'd like to catch win32 Ctrl+F4 key event.
Perhaps QShortcut (a.k.a QAccel) will be enough?


And, how do I install my own translation files?
Qt defines a global pointer to QApplication instance --- qApp. In Qt4 you can also use QApplication::instance(). All you have to do is to write a function (or a method of singleton class) that will be called to initialize your DLL (note that this should happen after QApplication instance was created).