QML Script Console

From Qt Wiki
Revision as of 16:34, 14 January 2015 by Maintenance script (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Inspecting Qt Quick Applications using a custom made QML Script Console component.

qmlviewer + qmlscriptconsole

The QML Script Console provides a “ScriptConsole” component. For each instance of a ScriptConsole inside your Qt Quick application a script editor window will be opened which allows you to inject code into the running application. Thereby you can test expression in the running application context.

To get started, download and build the plugin:

Once your build is complete, try to open the ‘test.qml’ shipped with the console.

Now try to modify the application state by entering something like:

The ‘test.qml’ contains the following:

As you can see, the script console is just another component. You can use the standard ‘print()’ function to inspect the QML object tree. For instance the following prints all attributes and methods which are exposed to the script environment:

Especially when you are building more complex expressions you may want to try them out first. For instance, the following displays the current time using the builtin Date object [developer.mozilla.org]:

As the ‘ScriptConsole’ itself is also a QML component, it is not protected against dynamic modification:

Categories: