1)
Qt Code:
Switch view
QT_FORWARD_DECLARE_CLASS(QTableView)
To copy to clipboard, switch view to plain text mode
Expands to:
Qt Code:
Switch view
namespace Foo { class QTableView; }
using ::Foo::QTableView;
To copy to clipboard, switch view to plain text mode
2)
Qt Code:
Switch view
QT_BEGIN_NAMESPACE
class QTableView
;
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
class QTableView;
QT_END_NAMESPACE
To copy to clipboard, switch view to plain text mode
Expands to:
Qt Code:
Switch view
namespace
Foo {
class QTableView
;
}
namespace Foo {
class QTableView;
}
To copy to clipboard, switch view to plain text mode
3)
Qt Code:
Switch view
class QTableView
;
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
Qt Code:
Switch view
using
namespace
::
Foo
;
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.
http://www.qtcentre.org/threads/15946-What-s-effect-of-QT_BEGIN_NAMESPACE-Thanks
using namespace ::Foo;
To copy to clipboard, switch view to plain text mode