在源代码中是这样定义的:
1
|
# define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE {
|
2
|
# define QT_END_NAMESPACE }
|
也就是说,如果你定义以下内容:
1
|
QT_BEGIN_NAMESPACE
|
2
|
class QListView;
|
3
|
QT_END_NAMESPACE
|
那么,在编译时就会变成这样:
1
|
namespace QT_NAMESPACE {
|
2
|
class QListView;
|
3
|
}
|
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.
仅当在编译Qt时,加上-qtnamespace选项时,这两个宏才会有作用,这时,Qt作为第三方库,要使用用户自定义的命名空间来访问Qt中的类,如QListView *view = new QT_NAMESPACE::QListView