8

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?

1
  • I found myself here and then figured out my problem: QML debugging works by a collaboration between the QApplication and the debugger, with the -qmljsdebugger flag, which magically gets consumed by the QApplication c'tor. I had made a "dummy" QAppliation in order to parse the command-line args before launching my app. As a result, the first QApplication consumed the arg, and so the "real" QApplication never saw it. Commented May 30, 2023 at 14:01

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

4 Comments

That does seem to fix the "QDeclarativeDebugServer ignoring" message. Now it says "Qml debugging is enabled. Only use this in a safe environment!" However the breakpoints are still not being hit in the QML.
Can you see a message like "QDeclarativeDebugServer: Waiting for connection on port 3768..." on the console?
When I use your "Qt4" solution I do get the message: "Qml debugging is enabled. Only use this in a safe environment! QDeclarativeDebugServer: Waiting for connection on port 40393... QDeclarativeDebugServer: Connection established"
However when I try the Qt5 solution (and adding Qt+=quick to my project) I get some confusing messages: "QML debugging is enabled. Only use this in a safe environment. "QDeclarativeDebugServer: Ignoring \"-qmljsdebugger=port:36014,block,services:DebugMessages,QmlDebugger,V8Debugger,QmlInspector\". Debugging has not been enabled.""
2

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)

Comments

2

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.