Qt VS Tools, QML Debugging
-
Hello there.
I have problem with breakpoints in QML files, they are not working in Visual Studio. In project settings "Enable QML Debugging" is set to "Yes".
In console there are this lines:Qt VS Tools: QML debug: Debugging Project 'project'... Qt VS Tools: QML Debug: Starting QML debug session... ... (QML): Connecting to the QML runtime... ... QML Debugger: Connecting to socket {...}... ...
So looks like the debugger is active, but why breakpoints does not work?
Qt 5.13.1, VS2015, Qt VS Tools 2.4.2
-
Posting for the sake of other developers searching for solutions of similar issues.
I had hard time using QML debugging within Visual Studio. The QML debug process mentioned in the original Qt blog post was starting but then exiting after a minute or so with the Debug output like
The thread 'QML Debugger' (0x457c) has exited with code 0 (0x0). The program 'My Application.exe: QML Debugger' has exited with code 0 (0x0).
My breakpoints in QML code were inactive with a tooltip
The breakpoint will not currently be hit. No symbols have been loaded for this document.
After some research, I found the following hint in the QML Debugging Infrastructure documentation:
Note: The
qmltooling
plugins that are required for debugging and profiling QML applications on devices are automatically installed during Qt installation. They must be deployed to the devices for debugging and profiling to work.Once I copied that directory from Qt into my application, next to other plug-in directories like
platforms
, from the next debugging session things started to work the way announced in the blog post.Qt 5.15.2, VS 2017 (15.9.34), Qt VS Tools 2.7.1-8.
-
After much back and forth, I finally figured out how to debug QML code using the current QT Visual Studio tools with CMake + Qt + Visual Studio IDE. First, if you have a project built with CMake + Qt, open the root directory of your project using the "Open Folder" method in Visual Studio 2022, and select the CMakeLists.txt file. At this point, Visual Studio 2022 IDE will create CMakePresets.json and CMakeUserPresets.json for you based on the QT Visual Studio tools.
At this stage, you can only modify CMakeUserPresets.json to configure the dependencies required for building your project, ensuring that your project can be successfully built. Once the build is successful, you can directly press F5 to start debugging.
I hope the method I discovered can help those who have this need.....