Solved Why we use "QT_USE_NAMESPACE" in some of Qt Programs?
-
Hi
In many cases I've seen that people use "QT_USE_NAMESPACE".
I googled it, and couldn't find anything..
What's the purpose of "QT_USE_NAMESPACE" , and why do we use it?
Why there is nothing about it around!!!! :/ -
Hi @PooyaSis
You can compile Qt yourself within a namespace, e.g. to use a diffent Qt version within a plugin than the program that loads the plugin uses. More information here: https://wiki.qt.io/Qt_In_Namespace
I have not seen QT_USE_NAMESPACE so far, only QT_BEGIN_NAMESPACE and QT_END_NAMESPACE.
Where did you see QT_USE_NAMESPACE?
-
@PooyaSis said in Why we use "QT_USE_NAMESPACE" in some of Qt Programs?:
QT_USE_NAMESPACE
Thanks a lot.
It was here in this example:http://doc.qt.io/qt-5/qtserialport-cwriterasync-serialportwriter-cpp.html
-
@PooyaSis
In Qt source code, you can checkqtbase/src/corelib/global/qglobal.h
You will find that#define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE;
Here is the source code, you can find it at line 133
https://github.com/qt/qtbase/blob/5.10/src/corelib/global/qglobal.h