diff --git a/src/plugins/projectexplorer/environmenteditmodel.cpp b/src/plugins/projectexplorer/environmenteditmodel.cpp
index bb7e4dda969d859047cf4b00bf2fde063f016a09..28ee8eae3fbcca13632c3e16bb56c54883fdfce7 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.cpp
+++ b/src/plugins/projectexplorer/environmenteditmodel.cpp
@@ -29,6 +29,9 @@
 
 #include "environmenteditmodel.h"
 
+#include <QtGui/QVBoxLayout>
+#include <QtGui/QHeaderView>
+
 using namespace ProjectExplorer;
 
 EnvironmentModel::EnvironmentModel()
@@ -416,3 +419,165 @@ void EnvironmentModel::setUserChanges(QList<EnvironmentItem> list)
     updateResultEnvironment();
     emit reset();
 }
+
+////
+// EnvironmentWidget::EnvironmentWidget
+////
+
+EnvironmentWidget::EnvironmentWidget(QWidget *parent)
+    : QWidget(parent)
+{
+    m_model = new EnvironmentModel();
+    m_model->setMergedEnvironments(true);
+    connect(m_model, SIGNAL(userChangesUpdated()),
+            this, SIGNAL(userChangesUpdated()));
+
+    QVBoxLayout *verticalLayout = new QVBoxLayout(this);
+    m_clearSystemEnvironmentCheckBox = new QCheckBox(this);
+    m_clearSystemEnvironmentCheckBox->setText("Clear system environment");
+    verticalLayout->addWidget(m_clearSystemEnvironmentCheckBox);
+
+    QHBoxLayout *horizontalLayout = new QHBoxLayout();
+    m_environmentTreeView = new QTreeView(this);
+    m_environmentTreeView->setRootIsDecorated(false);
+    m_environmentTreeView->setHeaderHidden(false);
+    m_environmentTreeView->setModel(m_model);
+    m_environmentTreeView->header()->resizeSection(0, 250);
+    horizontalLayout->addWidget(m_environmentTreeView);
+
+    QVBoxLayout *verticalLayout_2 = new QVBoxLayout();
+
+    m_editButton = new QPushButton(this);
+    m_editButton->setText("&Edit");
+    verticalLayout_2->addWidget(m_editButton);
+
+    m_addButton = new QPushButton(this);
+    m_addButton->setText("&Add");
+    verticalLayout_2->addWidget(m_addButton);
+
+    m_removeButton = new QPushButton(this);
+    m_removeButton->setEnabled(false);
+    m_removeButton->setText("&Reset");
+    verticalLayout_2->addWidget(m_removeButton);
+
+    m_unsetButton = new QPushButton(this);
+    m_unsetButton->setEnabled(false);
+    m_unsetButton->setText("&Unset");
+    verticalLayout_2->addWidget(m_unsetButton);
+
+    QSpacerItem *verticalSpacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
+    verticalLayout_2->addItem(verticalSpacer);
+    horizontalLayout->addLayout(verticalLayout_2);
+    verticalLayout->addLayout(horizontalLayout);
+
+    connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
+            this, SLOT(updateButtons()));
+
+    connect(m_editButton, SIGNAL(clicked(bool)),
+            this, SLOT(editEnvironmentButtonClicked()));
+    connect(m_addButton, SIGNAL(clicked(bool)),
+            this, SLOT(addEnvironmentButtonClicked()));
+    connect(m_removeButton, SIGNAL(clicked(bool)),
+            this, SLOT(removeEnvironmentButtonClicked()));
+    connect(m_unsetButton, SIGNAL(clicked(bool)),
+            this, SLOT(unsetEnvironmentButtonClicked()));
+    connect(m_environmentTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+            this, SLOT(environmentCurrentIndexChanged(QModelIndex, QModelIndex)));
+    connect(m_clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
+            this, SIGNAL(clearSystemEnvironmentCheckBoxClicked(bool)));
+}
+
+EnvironmentWidget::~EnvironmentWidget()
+{
+    delete m_model;
+    m_model = 0;
+}
+
+void EnvironmentWidget::setClearSystemEnvironment(bool b)
+{
+    m_clearSystemEnvironmentCheckBox->setChecked(b);
+}
+
+void EnvironmentWidget::setBaseEnvironment(const ProjectExplorer::Environment &env)
+{
+    m_model->setBaseEnvironment(env);
+}
+
+void EnvironmentWidget::setMergedEnvironments(bool b)
+{
+    m_model->setMergedEnvironments(b);
+}
+
+bool EnvironmentWidget::mergedEnvironments()
+{
+    return m_model->mergedEnvironments();
+}
+
+QList<EnvironmentItem> EnvironmentWidget::userChanges() const
+{
+    return m_model->userChanges();
+}
+
+void EnvironmentWidget::setUserChanges(QList<EnvironmentItem> list)
+{
+    m_model->setUserChanges(list);
+}
+
+void EnvironmentWidget::updateButtons()
+{
+    environmentCurrentIndexChanged(m_environmentTreeView->currentIndex(), QModelIndex());
+}
+
+void EnvironmentWidget::editEnvironmentButtonClicked()
+{
+    m_environmentTreeView->edit(m_environmentTreeView->currentIndex());
+}
+
+void EnvironmentWidget::addEnvironmentButtonClicked()
+{
+    QModelIndex index = m_model->addVariable();
+    m_environmentTreeView->setCurrentIndex(index);
+    m_environmentTreeView->edit(index);
+    updateButtons();
+}
+
+void EnvironmentWidget::removeEnvironmentButtonClicked()
+{
+    const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex());
+    m_model->removeVariable(name);
+    updateButtons();
+}
+
+// unset in Merged Environment Mode means, unset if it comes from the base environment
+// or remove when it is just a change we added
+// unset in changes view, means just unset
+void EnvironmentWidget::unsetEnvironmentButtonClicked()
+{
+    const QString &name = m_model->indexToVariable(m_environmentTreeView->currentIndex());
+    if (!m_model->isInBaseEnvironment(name) && m_model->mergedEnvironments())
+        m_model->removeVariable(name);
+    else
+        m_model->unset(name);
+    updateButtons();
+}
+
+void EnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &current, const QModelIndex &previous)
+{
+    Q_UNUSED(previous)
+    if (current.isValid()) {
+        if (m_model->mergedEnvironments()) {
+            const QString &name = m_model->indexToVariable(current);
+            bool modified = m_model->isInBaseEnvironment(name) && m_model->changes(name);
+            bool unset = m_model->isUnset(name);
+            m_removeButton->setEnabled(modified || unset);
+            m_unsetButton->setEnabled(!unset);
+        } else {
+            m_removeButton->setEnabled(true);
+            m_unsetButton->setEnabled(!m_model->isUnset(m_model->indexToVariable(current)));
+        }
+    } else {
+        m_editButton->setEnabled(current.isValid());
+        m_removeButton->setEnabled(false);
+        m_unsetButton->setEnabled(false);
+    }
+}
diff --git a/src/plugins/projectexplorer/environmenteditmodel.h b/src/plugins/projectexplorer/environmenteditmodel.h
index 3290a7430c23e3d2408400fe873972dc978df4a4..def0ca46f313df7abff2cee8f82f964681c3917a 100644
--- a/src/plugins/projectexplorer/environmenteditmodel.h
+++ b/src/plugins/projectexplorer/environmenteditmodel.h
@@ -35,7 +35,10 @@
 #include <QtCore/QString>
 #include <QtCore/QAbstractItemModel>
 #include <QtCore/QDebug>
-#include <QtGui/QFont>
+#include <QtGui/QWidget>
+#include <QtGui/QCheckBox>
+#include <QtGui/QTreeView>
+#include <QtGui/QPushButton>
 
 namespace ProjectExplorer {
 
@@ -84,6 +87,46 @@ private:
     bool m_mergedEnvironments;
 };
 
+
+class PROJECTEXPLORER_EXPORT EnvironmentWidget : public QWidget
+{
+    Q_OBJECT
+public:
+    EnvironmentWidget(QWidget *parent);
+    ~EnvironmentWidget();
+
+    void setBaseEnvironment(const ProjectExplorer::Environment &env);
+    void setMergedEnvironments(bool b);
+    void setClearSystemEnvironment(bool b);
+
+    bool mergedEnvironments();
+    QList<EnvironmentItem> userChanges() const;
+    void setUserChanges(QList<EnvironmentItem> list);
+
+public slots:
+    void updateButtons();
+
+signals:
+    void userChangesUpdated();
+    void clearSystemEnvironmentCheckBoxClicked(bool on);
+
+private slots:
+    void editEnvironmentButtonClicked();
+    void addEnvironmentButtonClicked();
+    void removeEnvironmentButtonClicked();
+    void unsetEnvironmentButtonClicked();
+    void environmentCurrentIndexChanged(const QModelIndex &current, const QModelIndex &previous);
+
+private:
+    EnvironmentModel *m_model;
+    QCheckBox *m_clearSystemEnvironmentCheckBox;
+    QTreeView *m_environmentTreeView;
+    QPushButton *m_editButton;
+    QPushButton *m_addButton;
+    QPushButton *m_removeButton;
+    QPushButton *m_unsetButton;
+};
+
 } // namespace ProjectExplorer
 
 #endif // ENVIRONMENTEDITMODEL_H
diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
index 0230cf9c32806a4f1878c63984af23fe4bca4ecf..1d5bfd1e704098bbe5dfaa99018bfe7d7b916f2a 100644
--- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.cpp
@@ -45,38 +45,20 @@ using ProjectExplorer::EnvironmentModel;
 Qt4BuildEnvironmentWidget::Qt4BuildEnvironmentWidget(Qt4Project *project)
     : BuildStepConfigWidget(), m_pro(project)
 {
-    m_ui = new Ui::Qt4BuildEnvironmentWidget();
-    m_ui->setupUi(this);
+    QVBoxLayout *vbox = new QVBoxLayout(this);
+    vbox->setMargin(0);
+    m_buildEnvironmentWidget = new ProjectExplorer::EnvironmentWidget(this);
+    vbox->addWidget(m_buildEnvironmentWidget);
 
-    m_environmentModel = new EnvironmentModel();
-    m_environmentModel->setMergedEnvironments(true);
-    m_ui->environmentTreeView->setModel(m_environmentModel);
-    m_ui->environmentTreeView->header()->resizeSection(0, 250);
-
-    connect(m_environmentModel, SIGNAL(userChangesUpdated()),
+    connect(m_buildEnvironmentWidget, SIGNAL(userChangesUpdated()),
             this, SLOT(environmentModelUserChangesUpdated()));
-
-    connect(m_environmentModel, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
-            this, SLOT(updateButtonsEnabled()));
-
-    connect(m_ui->editButton, SIGNAL(clicked(bool)),
-            this, SLOT(editEnvironmentButtonClicked()));
-    connect(m_ui->addButton, SIGNAL(clicked(bool)),
-            this, SLOT(addEnvironmentButtonClicked()));
-    connect(m_ui->removeButton, SIGNAL(clicked(bool)),
-            this, SLOT(removeEnvironmentButtonClicked()));
-    connect(m_ui->unsetButton, SIGNAL(clicked(bool)),
-            this, SLOT(unsetEnvironmentButtonClicked()));
-    connect(m_ui->environmentTreeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
-            this, SLOT(environmentCurrentIndexChanged(QModelIndex, QModelIndex)));
-    connect(m_ui->clearSystemEnvironmentCheckBox, SIGNAL(toggled(bool)),
+    connect(m_buildEnvironmentWidget, SIGNAL(clearSystemEnvironmentCheckBoxClicked(bool)),
             this, SLOT(clearSystemEnvironmentCheckBoxClicked(bool)));
 }
 
 Qt4BuildEnvironmentWidget::~Qt4BuildEnvironmentWidget()
 {
-    delete m_ui;
-    delete m_environmentModel;
+
 }
 
 QString Qt4BuildEnvironmentWidget::displayName() const
@@ -90,91 +72,20 @@ void Qt4BuildEnvironmentWidget::init(const QString &buildConfiguration)
         qDebug() << "Qt4BuildConfigWidget::init()";
 
     m_buildConfiguration = buildConfiguration;
-    m_ui->clearSystemEnvironmentCheckBox->setChecked(!m_pro->useSystemEnvironment(buildConfiguration));
-    m_environmentModel->setBaseEnvironment(m_pro->baseEnvironment(buildConfiguration));
-    m_environmentModel->setUserChanges(m_pro->userEnvironmentChanges(buildConfiguration));
-
-    updateButtonsEnabled();
-}
-
 
-void Qt4BuildEnvironmentWidget::editEnvironmentButtonClicked()
-{
-    m_ui->environmentTreeView->edit(m_ui->environmentTreeView->currentIndex());
-}
-
-void Qt4BuildEnvironmentWidget::addEnvironmentButtonClicked()
-{
-    QModelIndex index = m_environmentModel->addVariable();
-    m_ui->environmentTreeView->setCurrentIndex(index);
-    m_ui->environmentTreeView->edit(index);
-    updateButtonsEnabled();
+    m_buildEnvironmentWidget->setClearSystemEnvironment(!m_pro->useSystemEnvironment(buildConfiguration));
+    m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(buildConfiguration));
+    m_buildEnvironmentWidget->setUserChanges(m_pro->userEnvironmentChanges(buildConfiguration));
+    m_buildEnvironmentWidget->updateButtons();
 }
 
-void Qt4BuildEnvironmentWidget::removeEnvironmentButtonClicked()
-{
-    const QString &name = m_environmentModel->indexToVariable(m_ui->environmentTreeView->currentIndex());
-    m_environmentModel->removeVariable(name);
-    updateButtonsEnabled();
-}
-// unset in Merged Environment Mode means, unset if it comes from the base environment
-// or remove when it is just a change we added
-// unset in changes view, means just unset
-void Qt4BuildEnvironmentWidget::unsetEnvironmentButtonClicked()
-{
-    const QString &name = m_environmentModel->indexToVariable(m_ui->environmentTreeView->currentIndex());
-    if (!m_environmentModel->isInBaseEnvironment(name) && m_environmentModel->mergedEnvironments())
-        m_environmentModel->removeVariable(name);
-    else
-        m_environmentModel->unset(name);
-    updateButtonsEnabled();
-}
-
-void Qt4BuildEnvironmentWidget::switchEnvironmentTab(int newTab)
-{
-    bool mergedEnvironments = (newTab == 0);
-    m_environmentModel->setMergedEnvironments(mergedEnvironments);
-    if (mergedEnvironments) {
-        m_ui->removeButton->setText(tr("Reset"));
-    } else {
-        m_ui->removeButton->setText(tr("Remove"));
-    }
-}
-
-void Qt4BuildEnvironmentWidget::updateButtonsEnabled()
-{
-    environmentCurrentIndexChanged(m_ui->environmentTreeView->currentIndex(), QModelIndex());
-}
-
-void Qt4BuildEnvironmentWidget::environmentCurrentIndexChanged(const QModelIndex &current, const QModelIndex &previous)
+void Qt4BuildEnvironmentWidget::environmentModelUserChangesUpdated()
 {
-    Q_UNUSED(previous)
-    if (current.isValid()) {
-        if (m_environmentModel->mergedEnvironments()) {
-            const QString &name = m_environmentModel->indexToVariable(current);
-            bool modified = m_environmentModel->isInBaseEnvironment(name) && m_environmentModel->changes(name);
-            bool unset = m_environmentModel->isUnset(name);
-            m_ui->removeButton->setEnabled(modified || unset);
-            m_ui->unsetButton->setEnabled(!unset);
-            return;
-        } else {
-            m_ui->removeButton->setEnabled(true);
-            m_ui->unsetButton->setEnabled(!m_environmentModel->isUnset(m_environmentModel->indexToVariable(current)));
-            return;
-        }
-    }
-    m_ui->editButton->setEnabled(current.isValid());
-    m_ui->removeButton->setEnabled(false);
-    m_ui->unsetButton->setEnabled(false);
+    m_pro->setUserEnvironmentChanges(m_buildConfiguration, m_buildEnvironmentWidget->userChanges());
 }
 
 void Qt4BuildEnvironmentWidget::clearSystemEnvironmentCheckBoxClicked(bool checked)
 {
     m_pro->setUseSystemEnvironment(m_buildConfiguration, !checked);
-    m_environmentModel->setBaseEnvironment(m_pro->baseEnvironment(m_buildConfiguration));
-}
-
-void Qt4BuildEnvironmentWidget::environmentModelUserChangesUpdated()
-{
-    m_pro->setUserEnvironmentChanges(m_buildConfiguration, m_environmentModel->userChanges());
+    m_buildEnvironmentWidget->setBaseEnvironment(m_pro->baseEnvironment(m_buildConfiguration));
 }
diff --git a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h
index 46b7818d8e9f9091b09695fb4bcd70cef4ecfd42..b139704707c3313a022035b99c67f61192b86272 100644
--- a/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h
+++ b/src/plugins/qt4projectmanager/qt4buildenvironmentwidget.h
@@ -33,7 +33,7 @@
 #include <projectexplorer/buildstep.h>
 
 namespace ProjectExplorer {
-class EnvironmentModel;
+class EnvironmentWidget;
 }
 
 namespace Qt4ProjectManager {
@@ -41,11 +41,6 @@ namespace Qt4ProjectManager {
 class Qt4Project;
 
 namespace Internal {
-
-namespace Ui {
-class Qt4BuildEnvironmentWidget;
-}
-
 class Qt4BuildEnvironmentWidget : public ProjectExplorer::BuildStepConfigWidget
 {
     Q_OBJECT
@@ -59,19 +54,11 @@ public:
 
 private slots:
     void environmentModelUserChangesUpdated();
-    void editEnvironmentButtonClicked();
-    void addEnvironmentButtonClicked();
-    void removeEnvironmentButtonClicked();
-    void unsetEnvironmentButtonClicked();
-    void switchEnvironmentTab(int newTab);
-    void environmentCurrentIndexChanged(const QModelIndex &current, const QModelIndex &previous);
-    void clearSystemEnvironmentCheckBoxClicked(bool);
-    void updateButtonsEnabled();
+    void clearSystemEnvironmentCheckBoxClicked(bool checked);
 
 private:
-    Ui::Qt4BuildEnvironmentWidget *m_ui;
+    ProjectExplorer::EnvironmentWidget *m_buildEnvironmentWidget;
     Qt4Project *m_pro;
-    ProjectExplorer::EnvironmentModel *m_environmentModel;
     QString m_buildConfiguration;
 };
 
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 62c59936aae2f101de038e98d5c26ffbe05e96d7..ef87bc6ec03fed06aeef6229a90fb65136d7622f 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -786,6 +786,7 @@ void QtVersion::updateQMakeCXX() const
     reader->setParsePreAndPostFiles(false);
     reader->readProFile(mkspecPath() + "/qmake.conf");
     m_qmakeCXX = reader->value("QMAKE_CXX");
+
     delete reader;
     m_qmakeCXXUpToDate = true;
 }