Search code examples
linuxqtdebuggingqml

QtCreator breakpoint not reached in QML


I configurated my QtCreator project, to show a GUI written with QML and all the algorithmic part on a C++ class connected to my GUI (classic thing in Qt so far). What I want is to be able to debug the QML and the CPP to debug easier later in my project. For the example, I take the code from the The second tutorial of Qt for QML. I also followed the instruction of the Qt page which exaplins how to debug QML and CPP to configure my project.

My environment is:

  • Linux Red Hat 7
  • Qt Creator 4.8.2
  • Qt 5.12.2
  • GCC 4.8.5
  • Cmake 3.13.2
  • Make from GNU 4.1
  • Account without right to install anything :( but if really necessary I can ask for some installation software

The compilation is done without error. When I start the debugger, I have the following message:

QML debugging is enabled. Only use this in a safe environment.

----- EDIT1: not anymore this warning updating the sysroot parameter of the kit -----

So, all seem to be okay for the debugger. But a first weird thing happens at the start of the debugger, before to reach first breakpoint in the main.cpp without other warning or error, I have two messages like this which are pop between "Continue" action in the debugger:

Warning when starting debugger

With the following messages in the Linux terminal:

SOFT ASSERT: "state() == EngineRunRequested || state() == InferiorStopOk" in file /home/qt/work/build/qt-creator/src/plugins/debugger/gdb/gdbengine.cpp, line 4612 "InferiorRunRequested"

For me, it is just warning, because I can reach the first breakpoint of my main.cpp. But I prefer to give this information in case of it is something very wrong.

----- END EDIT1 -----

Another information is when I stop the debugger, I have the following message:

Error message stopping the debugger

For information, I have the following configuration of my project (you will see I have the case "Qml debugging and profiling" as mentioned in my link above):

Debug settings Run settings

And for my kit:

Kit configuration

Any help you can bring me will be appreciate because I am a novice in Linux and also to configure a project for the debugger. Until now, all was worked on first time but I change of project and PC. So thank you in advance !


Solution

  • I finally succeeded to make it works. How? Adding these two magic lines in the CMakelists.txt file:

    • set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG ") : to set the debug flag for the compiler about QML
    • TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) :