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@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to