Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Qt - Qml debugging and/or profiling?

What software Qt/QML pieces are needed to compile in an app to be able to debug/profile QML?

My current app is build using cmake and runs on a embedded device. Furthermore, I'm starting to use Qt 4.8.3 (until now 4.7.0).

I would like to use these fancy/cool features (for an embedded developer):

http://doc.qt.digia.com/qtcreator/creator-qml-performance-monitor.html

I've searched trough qt-project looking for help, but I haven't got clear what are the steps needed when you want to debug/profile a remote app, with a customize build environment.

So, I would like to know if it is needed any of the following steps, and in positive case, what is in fact the needed code.

  • Qt libraries ./configure specific options.
  • QtCreator specific options to attach/launch to remote app.
  • Cmake includes and libraries needed in the final app executable .

Any help, link, etc is welcomed.

like image 228
kikeenrique Avatar asked Nov 13 '12 18:11

kikeenrique


People also ask

How do I debug a QML file?

Starting QML Debugging To start the application, choose Debug > Start Debugging > Start Debugging of Startup Project or press F5. Once the application starts running, it behaves and performs as usual. You can then perform the following tasks: Debug JavaScript functions.

How do you use QML in Qt?

Creating and Running QML Projects For simple UI files such as this one, select File > New File or Project > Application (Qt Quick) > Qt Quick Application - Empty from within Qt Creator. Pressing the green Run button runs the application. You should see the text Hello, World! in the center of a red rectangle.

How do I debug QML in Visual Studio?

Setting Up QML Debugging The process of setting up debugging for Qt Quick projects depends on the type of the project: Qt Quick UI or Qt Quick Application. To debug Qt Quick UI projects: Select Projects, and then select the QML check box in the Run Settings, to enable QML debugging.


2 Answers

Checking the docs all given answers seem to be unnecessary. Further it hardcodes debug code in releases. I have no clue why QQmlDebuggingEnabler would be necessary, but if you check the code here and here, you will recognize, that the instatiation of QQmlDebuggingEnabler is not necessary. Just include QQmlDebuggingEnabler and set the QT_QML_DEBUG flag e.g. like this (CMake)

set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG ")

However according to the docs QQmlDebuggingEnabler is not necessary.

Furtermore: profiling unoptimized code makes no sense.

For me setting QT_QML_DEBUG as flag and checking the checkbox for QML debugging is sufficient.

like image 185
ManuelSchneid3r Avatar answered Sep 19 '22 12:09

ManuelSchneid3r


I'm using Qt 5, and it got even easier. Just this one step was required on my side to do QML profiling:

#include <QQmlDebuggingEnabler>

...

QQmlDebuggingEnabler enabler;
like image 32
Jan Rüegg Avatar answered Sep 17 '22 12:09

Jan Rüegg