Debugging QML with Qt creator - qt

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 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.

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)

Related

Why I cant debug qml from qt creator?

I installed the last Qt 5.12.2 . Then I open the cmake project via Qt Creator.
First I see a huge count on the intellisence issues: from "udeclared identifies of nullptr" to errors with each type "unknown type name".
The build proceeded successfully and I receive correct binary.
But any breakpoint marked as "Unclaimed breakpoint" and I cant debug any .qml (the .cpp could be debug)
So why it happens and how to debug the QML? (this future is still supported?)
UPDATE: The "QQmlDebuggingEnabler enabler;" and "doc.qt.io/qt-5/qtquick-debugging.html" doesnt helps :(
UPDATE2: #Amfasis -
I created a CMake-based Qt Quick project, and it shown that it supports QML/JS debugging. I checked the CMakeLists.txt, and found one relevant line:
target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
So I think if you'd like to debug your CMake-based Qt Quick project, you should also add this line to your CMakeLists.txt.
And don't forget to check on enable QML in the project setting within the sector of debugging setting.

Qt error with reMarkable tablet app

I have a reMarkable tablet , which I mostly love except for the lack of linux support (surprising given it is a linux-based OS). However, I've managed to find a version of a linux application that is now unofficial. This github is actually a Qt docker app, but if you look in the code for the 'Dockerfile' you can find where to download the app, which is apparently still on the server even though there's not a link from the main web page. Anyway, I downloaded it and got it mostly working, figuring out a few dependencies based on same Dockerfile code. But, I can't seem to get file dialogs to work, which is the main reason for using the app.
The error I get is:
ERROR: No native FileDialog implementation available.
Qt Labs Platform requires Qt Widgets on this setup.
Add 'QT += widgets' to .pro and create QApplication in main().
I'm not a Qt developer, so I'm lost. I'd love to get this to work. Thanks.
In the .pro file of you project you should add this line QT += widgets
or just add widgets to the line with QT += ...
Qt can use native file dialogs on some platforms, and will fall back to its own implementation if none is available. But that requires that the application is built including the QtWidgets module, and using a QApplication.
If you don't have the source code of the app and a possiblity to rebuild it, there's no chance to fix this from a binary

qbs QML debugging doesn't work

After migration to QBS my QML debugging stopped working.
I made sure that:
I'm building a debug build, C++ debugging works
I've checked "Enable QML Debugging" in qt creator's Project tab
I've even tried to add qbs properties manually Qt.declarative.qmlDebugging:true Qt.quick.qmlDebugging:true
Still QtCreator says:
Some breakpoints cannot be handled by the debugger languages currently active, and will be ignored.
QML debugging works with an old .pro
My system:
Linux archlinux 4.15.7-1-ARCH
QBS 1.10.1
Qt 5.10.1
It's not so clear, but there are TWO checkboxes.
One at the build step, and another one in the run step.
So to get QML Debugging working you have to check both of them.
I missed the one under the "Projects->Run->Debugger settings->Enable QML"
The upcoming 4.6 release of Qt Creator should be smarter about this and auto-enable the checkbox in the run settings if the one in the build settings gets enabled.

Permanently disable the 'run in terminal' option

I created a plain C++ with Qt program. I failed to achieve any application output. The fix for me was to disable the 'run in terminal' option in Qt Creator.
Anyway, I'd rather use the built-in application output pane for output than a separate terminal. I know I can change it per build configuration, but can make it disabled by default?
I'm using Qt Creator 3.4.2
Default state of this option depends on your project file.
For qmake, if you have CONFIG += console - then this checkbox is checked.
For qbs it's consoleApplication: true
If you want different behavior for new projects - you can create your own Qt Creator project wizard template.

Which c++ compiler to use qt5 win7

trying to create a GUI for the first time.
I've decided to try QT 5.0, but it keeps giving me the error:
error: Qt Creator needs a compiler set up to build. Configure a
compiler in the kit options.
I go into kit options, and I can choose a number of different Visual Studio 11 compilers, or a MinGW compiler.
I have tried pointing the MinGW compiler to several different .exe files in the minGW bin dir, like c++.exe, gcc.exe, g++.exe, etc. I still receive the error message.
Then I read somewhere that I need to use MSVC10 to compile, however I can not find this compiler anywhere.
I just need to create a simple window with a couple labels and text boxes and a button, and I can't even get as far as creating a window.
Thanks for any help
I had to install MSVC2010, and use that compiler.
First configure a compiler in the "Compilers" tab of the "Build & Run" section in the Creator options. Then you can chose a configured compiler in a kit. Then set your project to use that kit.

Resources