QtCreator在QML中断点未触发。

huangapple go评论75阅读模式
英文:

QtCreator breakpoint not reached in QML

问题

我配置了Qt Creator项目,以显示用QML编写的GUI和连接到我的GUI的C++类中的所有算法部分(到目前为止,Qt中的经典事物)。我想要能够调试QML和CPP,以便在项目后期更容易调试。例如,我使用了Qt for QML的第二个教程中的代码。我还按照Qt页面上说明如何调试QML和CPP的说明配置了我的项目。

我的环境是:

  • Linux Red Hat 7
  • Qt Creator 4.8.2
  • Qt 5.12.2
  • GCC 4.8.5
  • Cmake 3.13.2
  • GNU 4.1的Make
  • 无法安装任何软件的帐户 QtCreator在QML中断点未触发。 但如果真的有必要,我可以请求安装一些软件

编译没有错误。当我启动调试器时,我收到以下消息:

> QML调试已启用。仅在安全环境中使用此选项。

----- EDIT1:通过更新工具链的sysroot参数,不再出现此警告 -----

所以,调试器似乎一切正常。但在调试器启动之前,到达main.cpp的第一个断点之前,我有两条像这样的消息,它们在调试器中的“继续”操作之间弹出:

QtCreator在QML中断点未触发。

在Linux终端中显示以下消息:

> SOFT ASSERT:“state() == EngineRunRequested || state() == InferiorStopOk”位于文件/home/qt/work/build/qt-creator/src/plugins/debugger/gdb/gdbengine.cpp的第4612行
“InferiorRunRequested”

对我来说,这只是警告,因为我可以到达main.cpp的第一个断点。但我更愿意提供这些信息,以防它是某种非常严重的问题。

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

另一条信息是当我停止调试器时,我收到以下消息:

QtCreator在QML中断点未触发。

供参考,这是我的项目配置(您将看到我有“Qml调试和分析”选项,如我上面的链接中所提到的):

QtCreator在QML中断点未触发。
QtCreator在QML中断点未触发。

以及我的工具链配置:

QtCreator在QML中断点未触发。

您能提供的任何帮助都将受到赞赏,因为我在Linux和调试器项目配置方面是个新手。迄今为止,一切都很顺利,但我更换了项目和PC。所以在此提前致谢!

英文:

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 QtCreator在QML中断点未触发。 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:

QtCreator在QML中断点未触发。

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:

QtCreator在QML中断点未触发。

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):

QtCreator在QML中断点未触发。
QtCreator在QML中断点未触发。

And for my kit:

QtCreator在QML中断点未触发。

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 !

答案1

得分: 1

可能第一个错误是由您正在调试的代码引起的吗?在非调试模式下,代码是否正常运行?

另外,您是否在调试模式下运行代码?
最后,她的工具配置中的Sysroot参数指向垃圾箱中的文件夹似乎有点奇怪...

英文:

it is possible that the first error is caused by the code you are debugging? Does the code run correctly when not in debugging mode?

Also, are you running the code in Debug mode?
Finally, it looks a bit strange that she Sysroot parameter in your kit configuration points to a folder in the Trash...

答案2

得分: 0

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 ") : 为编译器设置关于 QML 的调试标志
  • TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) :
英文:

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>)
    :

huangapple
  • 本文由 发表于 2023年3月8日 16:58:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75671054.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定