Miguel Costa

QML Debugging in Visual Studio

Published Monday October 8th, 2018
8 Comments on QML Debugging in Visual Studio
Posted in Dev Loop, integration, Labs, Qt, Visual Studio, Windows

The next release of the Qt Visual Studio Tools, v2.3.0, will allow debugging of QML applications in Visual Studio. It will be possible to set breakpoints in QML files and step through the execution of QML code. While in break mode, it will be possible to watch variables and change their values, as well as evaluate arbitrary expressions. The QML debug session will run concurrently to the C++ debug session, so it will be possible to set breakpoints and watch variables in both C++ and QML during the same debug run of the application.

This new debugging feature of the Qt VS Tools integrates with the QML debugging infrastructure, a part of the Qt QML module which provides services for debugging, inspecting, and profiling applications via a TCP port. To extend the Visual Studio debugger with features of the QML debugging infrastructure, a Visual Studio QML debug engine is provided. This debug engine consists, for the most part, of implementations of interfaces from the Active Debugging 7 (AD7) extensibility framework for the Visual Studio debugger.

If a Qt project contains any QML resource files, starting a debug session (e.g. by pressing F5), besides launching the native application, now also connects to the QML debugging infrastructure of that application. This can be seen in the Processes window of the Visual Studio debugger: two processes are listed, a native process that corresponds to the actual physical process created for the C++ debugging session, and a QML process, which does not correspond to any physical process that is running on the machine, but rather represents the connection to the QML debugging runtime within the native process.


Since both a native process and a QML process are present, it is possible to request breakpoints both in C++ or QML code. The Visual Studio debugger will forward requests to the appropriate debug engine. As usual, a filled circular breakpoint marker in QML code indicates a valid breakpoint; this means that a breakpoint request for that file position has been sent to, and confirmed by the QML runtime.


When a breakpoint is hit, Visual Studio will show the current state of the call stack. Unlike other scenarios of debugging applications that use different languages (e.g. .NET + Native debugging), the QML debug engine does not provide true mixed mode debugging. It runs concurrently with the native debug engine and, from the point of view of the Visual Studio debugger, it is not related to the native process. This means that, even though it is possible to debug both C++ and QML in the same debugging session, the stack that is shown when a QML breakpoint is hit will only include QML function calls — the C++ context of those calls will not be available.


As in the case of native debugging, while in break mode, it is possible to view and modify the values of local variables, in the context of the currently active call stack frame, as well as create watches for any variable or expression. The Immediate window is also available for evaluation of any expression in the context of the current stack frame.


Moving the mouse over a QML expression pops up an instant watch window (or “DataTip”). The value of that expression in the current context is displayed and can also be modified.


QML debugging is enabled by default for any Qt QML application. It is possible to disable QML debugging, and revert to native-only debugging, by opening the Qt project settings dialog and setting the “QML Debug” option to “Disable”. In this dialog, it is also possible to change the port that is used by the QML debugging runtime.


As mentioned, the QML debugging feature of the Qt VS Tools will be available in the next version, scheduled for release in the Visual Studio Marketplace later this year. A preview version will shortly be available for download on the Qt website; we’ll post a quick update here when it is available.

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in Dev Loop, integration, Labs, Qt, Visual Studio, Windows


Vladimir says:

Sounds good! What about IntelliSense for QML Namespaces, Types/Properties (including those added from CPP code) and possible values (when they are enums)? Last time I checked this plugin QML support was as low as a simple syntax coloring.

Miguel Costa Miguel Costa says:

IntelliSense for QML is something that we’re definitely going to have in Visual Studio. However, it won’t be ready in time for this next release. We’ll post an update here as soon as we have more information.

Igor says:

What about Qt Quick Compiler ? Will the debugging work?

Miguel Costa Miguel Costa says:

We’re still looking into the best way to integrate the qtquickcompiler with the Qt VS Tools, so I don’t yet have a definitive answer to that question. But it might be that the qtquickcompiler has to be disabled for the QML debugging to work. In that case, the add-in will automatically make the required modifications to the project properties in debug configurations.

Paul Knopf says:

This is great!

I wonder if there is a way to integrate it into my C#/QML integration?


Miguel Costa Miguel Costa says:

Thanks. In the current approach, the QML debug session is launched when the native-only debug engine starts a QML application. But it should be possible to get it to work also with the mixed mode debugger. That way, you could have a single debug session with the qmlnet code running in the mixed mode debug engine, and the QML debugging running in parallel, connected to the QML runtime in the qmlnet native plugin. You would have to send the required arguments to the QApplication and also compile with QT_QML_DEBUG defined, as explained in http://doc.qt.io/qt-5/qtquick-debugging.html#qml-debugging-infrastructure.

Erwin says:

This is great, when is version 2.3 is going to be released?

Miguel Costa Miguel Costa says:

We plan to release the official version to the Visual Studio Marketplace later this year. However, in a few days we should have a preview version available for download from the Qt website.

Commenting closed.

Get started today with Qt Download now