[Interest] qApp macro equivalent for QApplication subclasses

André Somers andre at familiesomers.nl
Fri Mar 21 10:55:10 CET 2014


Constantin Makshin schreef op 21-3-2014 04:46:
> 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.
I think it may be confusing to do so. The meaning of qApp will be 
different depending on what includes you did in the file you call it 
from (or recursively in the other files you have included). I don't 
think that that is very good API, and prefer to make my own myApp define 
instead. Then, it is always clear what will be returned.

André
>
> 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
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140321/3427e2b1/attachment.html>


More information about the Interest mailing list