Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging QML with Qt creator

Tags:

debugging

qt

qml

I have a Qt (5.8.0) project using QML files. I would like to set breakpoints in the QML file using Qt creator (4.2.1) so I can follow the flow. However I cannot get it to work. I have enabled "Enable QML debugging and profiling" in the qmake build step and "Enable C++" and "Enable QML" in the run step.

The breakpoints in the C++ code are hit, but the QML are ignored. When starting I get the following message:

QDeclarativeDebugServer: Ignoring 
\"-qmljsdebugger=port:42715,block,services:DebugMessages,QmlDebugger,V8Debugger,QmlInspector\". 
Debugging has not been enabled.

When I try to debug QML files in demo projects like "Calendar" with the same kit it does work and breakpoints are hit.

Any ideas?

like image 420
Frank Avatar asked Apr 10 '18 08:04

Frank


2 Answers

Did you enable the QML Debugger in your code? I remember putting something like this into my code:

For Qt4:

#include <QtDeclarative/qdeclarativedebug.h>
QDeclarativeDebuggingEnabler qmldbg;

or in case of Qt5:

#include <QQmlDebuggingEnabler>
QQmlDebuggingEnabler enabler;

Also QML debugging needs to be activated in the Execution Settings: enter image description here

like image 131
Jens Avatar answered Nov 13 '22 19:11

Jens


I had to remove a package from my .pro file:

#CONFIG += qtquickcompiler

With this line commented out and confirming my project's build steps: "Enable QML debugging and profiling" was checked, the breakpoints worked.

like image 2
Luke Dupin Avatar answered Nov 13 '22 19:11

Luke Dupin