diff --git a/src/plugins/qmldesigner/components/propertyeditor/basiclayouts.h b/src/plugins/qmldesigner/components/propertyeditor/basiclayouts.h
index 527059dd3a63441acc0fc7e7c95c9d173c250822..8315129c9a82610e2d229912e4f74d49f18caa68 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/basiclayouts.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/basiclayouts.h
@@ -175,13 +175,13 @@ public:
     QVBoxLayoutObject(QObject *parent=0);
 };
 
-#endif // BASICLAYOUTS_H
-
-
-QT_END_NAMESPACE
 
 QML_DECLARE_TYPE(QBoxLayoutObject);
 QML_DECLARE_TYPE(QHBoxLayoutObject);
 QML_DECLARE_TYPE(QVBoxLayoutObject);
 
+QT_END_NAMESPACE
+
 QT_END_HEADER
+
+#endif // BASICLAYOUTS_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp
index 3ffdc18a9558a2146467f5f2650572ad0ff3f9ad..910e40be4704fded601d0a1a913fa6e0e0cf2685 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.cpp
@@ -1168,8 +1168,6 @@ public:
     {}
 };
 
-QT_END_NAMESPACE
-
 QML_DEFINE_EXTENDED_TYPE(Bauhaus,1,0,QWidget,QWidget,QWidgetDeclarativeUI);
 
 //display
@@ -1232,4 +1230,6 @@ QML_DEFINE_EXTENDED_TYPE(Bauhaus,1,0,QMenu,QMenu, QMenuDeclarativeUI)
 QML_DECLARE_TYPE(QTabObject);
 QML_DEFINE_TYPE(Qt,4,6,QTabObject,QTabObject); //### with namespacing, this should just be 'Tab'
 
+QT_END_NAMESPACE
+
 #include "basicwidgets.moc"
diff --git a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.h b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.h
index b44eac30f586a8483e08d4847d5855ff75ca3687..a59b8fa8ee609c640077a8c92088229531c422a0 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/basicwidgets.h
@@ -57,6 +57,8 @@
 #include "filewidget.h"
 #include "layoutwidget.h"
 
+QT_BEGIN_NAMESPACE
+
 QML_DECLARE_TYPE(QWidget);
 
 //display
@@ -94,16 +96,12 @@ QML_DECLARE_TYPE(QTabWidget);
 QML_DECLARE_TYPE(FileWidget);
 QML_DECLARE_TYPE(LayoutWidget);
 
-QT_BEGIN_NAMESPACE
-
 class Action : public QAction {
     Q_OBJECT
 public:
     Action(QObject *parent = 0) : QAction(parent) {}
 };
 
-QT_END_NAMESPACE
-
 QML_DECLARE_TYPE(QMenu);
 QML_DECLARE_TYPE(Action);
 
@@ -116,4 +114,6 @@ QML_DECLARE_TYPE(Action);
 
 //top-level windows?
 
+QT_END_NAMESPACE
+
 #endif // BASICWIDGETS_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/behaviordialog.h b/src/plugins/qmldesigner/components/propertyeditor/behaviordialog.h
index dfc763b4e39806ece529556b8b97fd86c643ad36..45b71d6eb6c5f036edcc657ddd8ad77d7847c7ad 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/behaviordialog.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/behaviordialog.h
@@ -93,6 +93,8 @@ private:
 
 };
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlDesigner::BehaviorWidget);
+QT_END_NAMESPACE
 
 #endif// BEHAVIORDIALOG_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
index 3031da969c5f9fc2db2d70daab68468ec4391df6..5cb4b6218f8e6dc7db2e220715e6a6455cafa0f7 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/colorwidget.h
@@ -301,8 +301,10 @@ private:
 
 } //QmlDesigner
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlDesigner::ColorButton);
 QML_DECLARE_TYPE(QmlDesigner::HueControl);
 QML_DECLARE_TYPE(QmlDesigner::ColorBox);
+QT_END_NAMESPACE
 
 #endif //COLORWIDGET_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h b/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h
index d04e5e4e332dd7c40d28d7afbfcd65c8105d2209..bb30aa630d915769402e7e7ef1b9a6437c63c0a9 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/fontwidget.h
@@ -96,6 +96,8 @@ private: //variables
 
 } // namespace QmlDesigner
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlDesigner::FontWidget);
+QT_END_NAMESPACE
 
 #endif // FONTWIDGET_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
index ae9256a05e058dd3b442e7261f0c33d79f73877e..3b5b7fbd091214641ecb73d83e44bdce00b52e61 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.h
@@ -146,9 +146,11 @@ private: //variables
     QmlDesigner::RewriterTransaction m_rewriterTransaction;
 };
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(PropertyEditorValue);
 QML_DECLARE_TYPE(PropertyEditorNodeWrapper);
 QML_DECLARE_TYPE(QmlPropertyMap);
+QT_END_NAMESPACE
 
 
 #endif // PROPERTYEDITORVALUE_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h b/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h
index 13b79862b468e4b61577714ce9d18f16617d8734..be4ea3dd91a2bf72e548b1560ae80f5de9e532a4 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/qlayoutobject.h
@@ -49,10 +49,10 @@ public:
     virtual QLayout *layout() const;
 };
 
-QT_END_NAMESPACE
-
 QML_DECLARE_TYPE(QLayoutObject);
 
+QT_END_NAMESPACE
+
 QT_END_HEADER
 
 #endif // QLAYOUTOBJECT_H
diff --git a/src/plugins/qmldesigner/components/propertyeditor/qproxylayoutitem.h b/src/plugins/qmldesigner/components/propertyeditor/qproxylayoutitem.h
index f511489e8048affe7426e86ee48274abbaa26949..1e296e5658e33711bba2326e62186b2d92809e89 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/qproxylayoutitem.h
+++ b/src/plugins/qmldesigner/components/propertyeditor/qproxylayoutitem.h
@@ -87,11 +87,12 @@ private:
     QGraphicsLayoutItem *other;
 };
 
-#endif // QPROXYLAYOUTITEM_H
-
-QT_END_NAMESPACE
-
 QML_DECLARE_TYPE(QProxyLayout);
 QML_DECLARE_TYPE(QProxyLayoutItem);
 
+QT_END_NAMESPACE
+
 QT_END_HEADER
+
+#endif // QPROXYLAYOUTITEM_H
+
diff --git a/src/plugins/qmldesigner/components/propertyeditor/resetwidget.cpp b/src/plugins/qmldesigner/components/propertyeditor/resetwidget.cpp
index 3d74b2815e9f3d1557c9d0bbbfa101af67ae18f2..c1fdccdab1a99219cc56e91cdd23ccd98fbd3f12 100644
--- a/src/plugins/qmldesigner/components/propertyeditor/resetwidget.cpp
+++ b/src/plugins/qmldesigner/components/propertyeditor/resetwidget.cpp
@@ -40,9 +40,10 @@
 #include <QDebug>
 #include <QApplication>
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlDesigner::ResetWidget);
 QML_DEFINE_TYPE(Bauhaus, 1, 0, ResetWidget, QmlDesigner::ResetWidget);
-
+QT_END_NAMESPACE
 
 namespace QmlDesigner {
 
diff --git a/src/plugins/qmldesigner/core/instances/qmlpropertychangesnodeinstance.h b/src/plugins/qmldesigner/core/instances/qmlpropertychangesnodeinstance.h
index a928621ce6886dcda34d1a7b24bb6e8ff05daf27..ec70d21c7aa66b8c89a90d1fb2dda04c107498a0 100644
--- a/src/plugins/qmldesigner/core/instances/qmlpropertychangesnodeinstance.h
+++ b/src/plugins/qmldesigner/core/instances/qmlpropertychangesnodeinstance.h
@@ -98,6 +98,8 @@ protected:
 } // namespace Internal
 } // namespace QmlDesigner
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject)
+QT_END_NAMESPACE
 
 #endif // QMLPROPERTYCHANGESNODEINSTANCE_H
diff --git a/src/plugins/qmlprojectmanager/fileformat/filefilteritems.h b/src/plugins/qmlprojectmanager/fileformat/filefilteritems.h
index 575fd89e12d137050f8bf0aa00c47fd3e4e334d6..0a1e53ef5eef280e23fa2514630e27ffc5f6a3d4 100644
--- a/src/plugins/qmlprojectmanager/fileformat/filefilteritems.h
+++ b/src/plugins/qmlprojectmanager/fileformat/filefilteritems.h
@@ -104,9 +104,11 @@ public:
 
 } // namespace QmlProjectManager
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlProjectManager::QmlFileFilterItem)
 QML_DECLARE_TYPE(QmlProjectManager::JsFileFilterItem)
 QML_DECLARE_TYPE(QmlProjectManager::ImageFileFilterItem)
 QML_DECLARE_TYPE(QmlProjectManager::CssFileFilterItem)
+QT_END_NAMESPACE
 
 #endif // FILEFILTERITEMS_HPROJECTITEM_H
diff --git a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h
index 99e2c5c31abe9bdcdb616feccdc9b630ba34188b..6fc8f5cbab2ae7a6a7f8fcf6828e5d37903aa9af 100644
--- a/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h
+++ b/src/plugins/qmlprojectmanager/fileformat/qmlprojectitem.h
@@ -53,9 +53,11 @@ protected:
 
 } // namespace QmlProjectManager
 
+QT_BEGIN_NAMESPACE
 QML_DECLARE_TYPE(QmlProjectManager::QmlProjectItem);
 QML_DECLARE_TYPE(QmlProjectManager::QmlProjectContentItem);
-Q_DECLARE_METATYPE(QList<QmlProjectManager::QmlProjectContentItem *>);
+QT_DECLARE_METATYPE(QList<QmlProjectManager::QmlProjectContentItem *>);
+QT_END_NAMESPACE
 
 
 #endif // PROJECTITEM_H