简体   繁体   中英

Debugging QML with Qt creator

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?

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: 在此输入图像描述

I found a way to make it work. Looks like I am using the combination of Qt5, while using the Declarative package and Qt Quick 1.1. When I removed the Declarative package and instead use the qml and quick packages (Qt+=qml quick) and updated my software to use Qt Quick 2.2, the breakpoints were hit (also using the #include as suggested by the answer of 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM