Home · All Classes · All Functions · Overviews

Debugging QML

Logging

console.log can be used to print debugging information to the console. For example:

 Rectangle {
     width: 200; height: 200
     MouseArea {
         anchors.fill: parent
         onClicked: console.log("clicked")
     }
 }

Debugging Transitions

When a transition doesn't look quite right, it can be helpful to view it in slow motion to see what is happening more clearly. qmlviewer provides a "Slow Down Animations" menu option to facilitate this.

The QML Inspector

The qmldebugger tool provides an experimental inspector to aid with debugging. It can be run as a Qt Creator plugin or as a standalone application.

Qt Creator plugin

The Qt Creator plugin currently builds against Qt Creator 1.3.

To build the Qt Creator plugin:

This builds the plugin into your Qt Creator installation.

The plugin adds a "QML Inspect" mode into Qt Creator that provides:

To start the debugger, open a QML project and click the "QML Inspect" mode, then click the green "play" button in the toolbar of the bottom-right debugger window.

Standalone qmldebugger tool

To run the standalone qmldebugger tool, set an environment variable QML_DEBUG_SERVER_PORT to an available port number and run the qmlviewer. For example:

     QML_DEBUG_SERVER_PORT=3768 qmlviewer myqmlfile.qml

Then in another process, start the qmldebugger tool, enter the port number into the corresponding spinbox in the top right hand corner, and press the "Connect" button.


Copyright © 2010 Nokia Corporation and/or its subsidiary(-ies) Trademarks
Qt 4.7.0