Let's say one configures Qt with -qtnamespace Foo.
1)
QT_FORWARD_DECLARE_CLASS(QTableView)
To copy to clipboard, switch view to plain text mode
Expands to:
namespace Foo { class QTableView; }
using ::Foo::QTableView;
To copy to clipboard, switch view to plain text mode
2)
QT_BEGIN_NAMESPACE
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
class QTableView;
QT_END_NAMESPACE
To copy to clipboard, switch view to plain text mode
Expands to:
namespace Foo {
}
namespace Foo {
class QTableView;
}
To copy to clipboard, switch view to plain text mode
3)
class QTableView;
To copy to clipboard, switch view to plain text mode
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
using namespace ::Foo;
using namespace ::Foo;
To copy to clipboard, switch view to plain text mode
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.
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.
Bookmarks