Is it important to declare the namespace with QT_BEGIN_NAMESPACE .. QT_END_NAMESPACE

后端 未结 1 1633
春和景丽
春和景丽 2020-12-25 14:52

What is the effect of QT_BEGIN_NAMESPACE?

QT_BEGIN_NAMESPACE
class QLineEdit;
QT_END_NAMESPACE

If I don\'t use the class declaration like t

相关标签:
1条回答
  • 2020-12-25 15:35

    QT_BEGIN_NAMESPACE and QT_END_NAMESPACE are preprocessor macros and they are defined in QtGlobal as:

    #define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
    #define QT_END_NAMESPACE }
    

    But: those two macros only have any effect when Qt was configured and built using the -qtnamespace option, which allows you to build Qt inside a user-defined namespace.

    So: if you don't use (or plan on using) a Qt library which was built this way (per default, the Qt library resides in the global namespace), omitting the QT_BEGIN_NAMESPACE and QT_END_NAMESPACE won't lead to any problems.

    0 讨论(0)
提交回复
热议问题