diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
index 72c6081046eda7e54f1b60f919b4198ecea7e08f..141f5a77aeeb13a90d67c8826c88c433ecf2f854 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.cpp
@@ -44,6 +44,7 @@
 #include <debugger/debuggerengine.h>
 #include <debugger/debuggerplugin.h>
 #include <debugger/debuggerrunner.h>
+#include <debugger/qml/qmlcppengine.h>
 #include <debugger/gdb/remotegdbserveradapter.h>
 #include <debugger/gdb/remoteplaingdbadapter.h>
 #include <projectexplorer/toolchain.h>
@@ -63,12 +64,18 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
 {
     DebuggerStartParameters params;
     const MaemoDeviceConfig &devConf = runConfig->deviceConfig();
+
+    if (runConfig->useQmlDebugger()) {
+        params.qmlServerAddress = runConfig->deviceConfig().server.host;
+        params.qmlServerPort = qmlServerPort(runConfig);
+    }
+
     if (runConfig->useRemoteGdb()) {
         params.startMode = StartRemoteGdb;
         params.executable = runConfig->remoteExecutableFilePath();
         params.debuggerCommand
             = MaemoGlobal::remoteCommandPrefix(runConfig->remoteExecutableFilePath())
-                + QLatin1String(" /usr/bin/gdb");
+                + environment(runConfig) + QLatin1String(" /usr/bin/gdb");
         params.connParams = devConf.server;
         params.localMountDir = runConfig->localDirToMountForRemoteGdb();
         params.remoteMountPoint = MaemoGlobal::remoteProjectSourcesMountPoint();
@@ -84,9 +91,11 @@ RunControl *MaemoDebugSupport::createDebugRunControl(MaemoRunConfiguration *runC
         params.debuggerCommand = runConfig->gdbCmd();
         params.remoteChannel = devConf.server.host + QLatin1Char(':')
             + QString::number(gdbServerPort(runConfig));
+
         params.useServerStartScript = true;
         params.remoteArchitecture = QLatin1String("arm");
     }
+
     params.processArgs = runConfig->arguments();
     params.sysRoot = runConfig->sysRoot();
     params.toolChainType = ToolChain::GCC_MAEMO;
@@ -106,9 +115,15 @@ MaemoDebugSupport::MaemoDebugSupport(MaemoRunConfiguration *runConfig,
       m_deviceConfig(m_runConfig->deviceConfig()),
       m_runner(new MaemoSshRunner(this, m_runConfig, true))
 {
-    GdbEngine *engine = qobject_cast<GdbEngine *>(m_runControl->engine());
-    Q_ASSERT(engine);
-    m_gdbAdapter = engine->gdbAdapter();
+    GdbEngine *gdbEngine = qobject_cast<GdbEngine *>(m_runControl->engine());
+    if (!gdbEngine) {
+        QmlCppEngine * const qmlEngine
+            = qobject_cast<QmlCppEngine *>(m_runControl->engine());
+        Q_ASSERT(qmlEngine);
+        gdbEngine = qobject_cast<GdbEngine *>(qmlEngine->cppEngine());
+    }
+    Q_ASSERT(gdbEngine);
+    m_gdbAdapter = gdbEngine->gdbAdapter();
     Q_ASSERT(m_gdbAdapter);
     connect(m_gdbAdapter, SIGNAL(requestSetup()), this,
         SLOT(handleAdapterSetupRequested()));
@@ -230,9 +245,9 @@ void MaemoDebugSupport::startDebugging()
         connect(m_runner, SIGNAL(remoteProcessStarted()), this,
             SLOT(handleRemoteProcessStarted()));
         const QString &remoteExe = m_runConfig->remoteExecutableFilePath();
-        m_runner->startExecution(QString::fromLocal8Bit("%1 gdbserver :%2 %3 %4")
+        m_runner->startExecution(QString::fromLocal8Bit("%1 %2 gdbserver :%3 %4 %5")
             .arg(MaemoGlobal::remoteCommandPrefix(remoteExe))
-            .arg(gdbServerPort(m_runConfig))
+            .arg(environment(m_runConfig)).arg(gdbServerPort(m_runConfig))
             .arg(remoteExe).arg(m_runConfig->arguments()
             .join(QLatin1String(" "))).toUtf8());
     }
@@ -299,6 +314,23 @@ int MaemoDebugSupport::gdbServerPort(const MaemoRunConfiguration *rc)
     return rc->freePorts().getNext();
 }
 
+int MaemoDebugSupport::qmlServerPort(const MaemoRunConfiguration *rc)
+{
+    MaemoPortList portList = rc->freePorts();
+    portList.getNext();
+    return portList.getNext();
+}
+
+QString MaemoDebugSupport::environment(const MaemoRunConfiguration *rc)
+{
+    QList<EnvironmentItem> env = rc->userEnvironmentChanges();
+    if (rc->useQmlDebugger()) {
+        env << EnvironmentItem(QLatin1String(Debugger::Constants::E_QML_DEBUG_SERVER_PORT),
+            QString::number(qmlServerPort(rc)));
+    }
+    return MaemoGlobal::remoteEnvironment(env);
+}
+
 QString MaemoDebugSupport::uploadDir(const MaemoDeviceConfig &devConf)
 {
     return MaemoGlobal::homeDirOnDevice(devConf.server.uname);
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
index 4680487c7997df6186d012adca4d2061b2ab7907..eec6cdb22ff3218e413392369911bb468cca29fc 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemodebugsupport.h
@@ -86,6 +86,8 @@ private slots:
 
 private:
     static int gdbServerPort(const MaemoRunConfiguration *rc);
+    static int qmlServerPort(const MaemoRunConfiguration *rc);
+    static QString environment(const MaemoRunConfiguration *rc);
 
     void stopSsh();
     void handleAdapterSetupFailed(const QString &error);
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp
index d260c4bdd32f3bc0d288da819d657e7e3930ac01..a2212eec2cd74caaaca393af7632b8b734f95b8b 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.cpp
@@ -51,6 +51,7 @@
 #include <qt4projectmanager/qt4target.h>
 #include <utils/detailswidget.h>
 
+#include <QtGui/QCheckBox>
 #include <QtGui/QComboBox>
 #include <QtGui/QFileDialog>
 #include <QtGui/QFormLayout>
@@ -122,12 +123,18 @@ void MaemoRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayout)
     m_argsLineEdit = new QLineEdit(m_runConfiguration->arguments().join(" "));
     formLayout->addRow(tr("Arguments:"), m_argsLineEdit);
 
+    m_qmlCheckBox = new QCheckBox(tr("Also debug QML parts"));
+    m_qmlCheckBox->setChecked(m_runConfiguration->useQmlDebugger());
+    formLayout->addRow(new QLabel(tr("Debugging:")), m_qmlCheckBox);
+
     connect(addDevConfLabel, SIGNAL(linkActivated(QString)), this,
         SLOT(showSettingsDialog(QString)));
     connect(debuggerConfLabel, SIGNAL(linkActivated(QString)), this,
         SLOT(showSettingsDialog(QString)));
     connect(m_argsLineEdit, SIGNAL(textEdited(QString)), this,
         SLOT(argumentsEdited(QString)));
+    connect(m_qmlCheckBox, SIGNAL(toggled(bool)), this,
+        SLOT(handleQmlDebuggingChanged(bool)));
     connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this,
         SLOT(updateTargetInformation()));
     connect(m_runConfiguration->deployStep()->deployables(),
@@ -423,6 +430,12 @@ void MaemoRunConfigurationWidget::handleRemoteMountsChanged()
     updateMountWarning();
 }
 
+void MaemoRunConfigurationWidget::handleQmlDebuggingChanged(bool debugQml)
+{
+    m_runConfiguration->setUseQmlDebugger(debugQml);
+    updateMountWarning();
+}
+
 void MaemoRunConfigurationWidget::updateMountWarning()
 {
     QString mountWarning;
@@ -436,11 +449,16 @@ void MaemoRunConfigurationWidget::updateMountWarning()
                 "your device has only %2 free ports.<br>You will not be able "
                 "to run this configuration.")
             .arg(mountDirCount).arg(availablePortCount);
-        } else if (mountDirCount > 0 && mountDirCount == availablePortCount) {
-            mountWarning = tr("WARNING: The directories you want to mount will "
-                "use all %1 free ports on the device.<br>You will not be able "
-                "to debug your application with this configuration.")
-                .arg(availablePortCount);
+        } else if (mountDirCount > 0) {
+            const int portsLeftByDebuggers
+                = availablePortCount - 1 - m_runConfiguration->useQmlDebugger();
+            if (mountDirCount > portsLeftByDebuggers) {
+                mountWarning = tr("WARNING: You want to mount %1 directories, "
+                    "but only %2 ports on the device will be available "
+                    "in debug mode. <br>You will not be able to debug your "
+                    "application with this configuration.").
+                    arg(mountDirCount).arg(portsLeftByDebuggers);
+            }
         }
     }
     if (mountWarning.isEmpty()) {
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h
index 303102f165b5c06f0372677d76771aa800159590..1f0ae52f7fb3bb177cc43337ab75a1267b6aeec5 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunconfigurationwidget.h
@@ -38,6 +38,7 @@
 #include <QtGui/QWidget>
 
 QT_BEGIN_NAMESPACE
+class QCheckBox;
 class QComboBox;
 class QLabel;
 class QLineEdit;
@@ -87,6 +88,7 @@ private slots:
     void systemEnvironmentChanged();
     void userEnvironmentChangesChanged(const QList<ProjectExplorer::EnvironmentItem> &userChanges);
     void handleRemoteMountsChanged();
+    void handleQmlDebuggingChanged(bool debugQml);
     void handleDeploySpecsChanged();
     void handleBuildConfigChanged();
     void handleToolchainChanged();
@@ -102,6 +104,7 @@ private:
     QLabel *m_localExecutableLabel;
     QLabel *m_remoteExecutableLabel;
     QLabel *m_devConfLabel;
+    QCheckBox *m_qmlCheckBox;
     QLabel *m_mountWarningLabel;
     QTableView *m_mountView;
     QToolButton *m_removeMountButton;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemorunfactories.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemorunfactories.cpp
index 20a4c85a3939a36cea6d3912854b9e59164a5dfd..dad1736d5a974915c05f29aadf83f8a34490e698 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemorunfactories.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemorunfactories.cpp
@@ -169,7 +169,7 @@ bool MaemoRunControlFactory::canRun(RunConfiguration *runConfiguration,
     const int mountDirCount
         = maemoRunConfig->remoteMounts()->validMountSpecificationCount();
     if (mode == ProjectExplorer::Constants::DEBUGMODE)
-        return freePortCount > mountDirCount;
+        return freePortCount > mountDirCount + runConfiguration->useQmlDebugger();
     if (mode == ProjectExplorer::Constants::RUNMODE)
         return freePortCount >= mountDirCount;
     return false;
diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
index 9cfb8c2eb73b1c10c1dda7147ae3c310507b572a..06f4508337a8f3e10bb15573e5652b04e51e1a67 100644
--- a/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
+++ b/src/plugins/qt4projectmanager/qt-maemo/maemosshrunner.cpp
@@ -191,8 +191,12 @@ void MaemoSshRunner::handleUnmounted()
             return;
         m_mounter->resetMountSpecifications();
         MaemoPortList portList = m_devConfig.freePorts();
-        if (m_debugging && !m_runConfig->useRemoteGdb())
-            portList.getNext(); // One has already been used for gdbserver.
+        if (m_debugging) { // gdbserver and QML inspector need one port each.
+            if (!m_runConfig->useRemoteGdb())
+                portList.getNext();
+            if (m_runConfig->useQmlDebugger())
+                portList.getNext();
+        }
         m_mounter->setToolchain(m_runConfig->toolchain());
         m_mounter->setPortList(portList);
         const MaemoRemoteMountsModel * const remoteMounts