What's effect of QT_BEGIN_NAMESPACE/QT_END_NAMESPACE pair? Thanks
Printable View
What's effect of QT_BEGIN_NAMESPACE/QT_END_NAMESPACE pair? Thanks
It is possible to compile whole Qt inside a user-defined namespace. See configure options for more details. These macros expand as:
Code:
# define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE { # define QT_END_NAMESPACE }
Thank you!
I still don't get it. This is one of those things in Qt that is not documented well.
It is possible to compile Qt inside any given namespace. See configure -help for more details. These macros ensure that Qt classes are properly declared inside the given namespace if any.
What are the difference between
and
and
in a header file of a QtClass (like a MainWindow)?
Let's say one configures Qt with -qtnamespace Foo.
1)
Expands to:
2)
Expands to:
3)
Will cause a conflict because QTableView is forward declared outside the appropriate namespace, whereas including <QTableView> in the .cpp file brings in another QTableView declared inside the namespace and <QtGlobal> says
in order to make client code compile regardless of the Qt namespace usage. So QTableView becomes ambiguous and the compiler doesn't know which one to use, QTableView or Foo::QTableView.Code:
using namespace ::Foo;
Summary: Plain "class QTableView;" works as long as Qt is not compiled in a namespace. Using the macros will make your code more compatible. As far as I remember, for example the Eclipse integration requires Qt to be compiled in a certain namespace.
how do you configure that option ?
where do I put it ? inside pro file ?
thanx
just go to the QTDIR and run configure with -help option for deatails. You declare namespace name while use configure before building Qt
oh .. so this means I will have to compile QT separate for every project ?
if you want qt for every project in another namespace, then yes.