[Interest] qApp macro equivalent for QApplication subclasses

Constantin Makshin cmakshin at gmail.com
Fri Mar 21 04:46:08 CET 2014


I don't see anything bad even in redefining the "qApp" macro itself
(inclusion guards in Qt headers will protect your redefinition from
being reverted) instead of inventing your "myApp" one.

On 03/20/2014 10:58 PM, Andrej Kacian wrote:
> 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140321/2fb4a1bf/attachment.sig>


More information about the Interest mailing list