[Interest] qApp macro equivalent for QApplication subclasses

Andrej Kacian andrej at kacian.sk
Thu Mar 20 19:58:54 CET 2014


Hello all,

I was wondering, if I subclass QApplication for my program, is it a good idea
to just copy and adjust the definition of "qApp" macro if I want to use a
similar macro to refer to my subclass from anywhere?

E.g.:
#if defined(myApp)
#undef myApp
#endif
#define myApp (static_cast<MyApplication *>(QCoreApplication::instance()))

(taken from Qt 4.8 source code)

Is this a proper way, or will it bring some problems along the way?

Thanks
-- 
Andrej



More information about the Interest mailing list