2011-09-27 11:52:34 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2011-09-27 11:52:34 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator
|
2011-09-27 11:52:34 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Free Documentation License
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file included in the packaging of this
|
|
|
|
|
** file.
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// NOTE: the sections are not ordered by their logical order to avoid
|
|
|
|
|
// reshuffling the file each time the index order changes (i.e., often).
|
|
|
|
|
// Run the fixnavi.pl script to adjust the links to the index order.
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\contentspage index.html
|
|
|
|
|
\previouspage creator-debugging-helpers.html
|
|
|
|
|
\page creator-debugging-qml.html
|
2012-04-16 15:09:32 +02:00
|
|
|
\nextpage creator-debugging-example.html
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\title Debugging Qt Quick Projects
|
|
|
|
|
|
|
|
|
|
\note You need Qt 4.7.1 or later to debug Qt Quick projects. Debugging
|
|
|
|
|
projects not created with the Qt Quick wizards is only supported with
|
|
|
|
|
Qt 4.8, or later.
|
|
|
|
|
|
|
|
|
|
To debug Qt Quick applications running on devices, you must install
|
2012-08-22 13:27:25 +02:00
|
|
|
Qt 4.7.4, or later, libraries on devices.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2012-01-09 11:04:29 +01:00
|
|
|
For an example of how to debug Qt Quick Projects, see
|
|
|
|
|
\l{Debugging a Qt Quick Example Application}.
|
|
|
|
|
|
2011-09-27 11:52:34 +02:00
|
|
|
\section1 Setting Up QML Debugging
|
|
|
|
|
|
|
|
|
|
The process of setting up debugging for Qt Quick projects depends on the
|
2012-01-09 11:04:29 +01:00
|
|
|
\l{Creating Qt Quick Projects}{type of the project}: Qt Quick UI or Qt Quick
|
|
|
|
|
Application, and the Qt version used.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
To debug Qt Quick UI projects:
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li In \gui Projects mode \gui {Run Settings}, select the
|
2012-03-21 12:11:40 +01:00
|
|
|
\gui {Enable QML} check box in the \gui {Debugger Settings} to
|
|
|
|
|
enable QML debugging.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li For Qt 4.7, compile the QML Inspector debugging helper. For more information,
|
2011-09-27 11:52:34 +02:00
|
|
|
see \l{Debugging Helpers for QML}.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To debug Qt Quick Applications:
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Debugging is enabled by default for Qt 4.8, or later. For Qt 4.7,
|
2012-01-09 11:04:29 +01:00
|
|
|
select \gui Projects, and then select the
|
2011-11-16 09:33:22 +01:00
|
|
|
\gui {Enable QML debugging} check box in the \gui qmake section
|
|
|
|
|
in \gui {Build Steps}.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
You might have to compile the library first, by selecting the
|
|
|
|
|
\gui Compile link.
|
|
|
|
|
|
|
|
|
|
\image qml-link-debugging-library.png "Build Steps"
|
|
|
|
|
|
|
|
|
|
\note Debugging requires opening a socket at a well-known port,
|
|
|
|
|
which presents a security risk. Anyone on the Internet could connect
|
|
|
|
|
to the application that you are debugging and execute any JavaScript
|
|
|
|
|
functions. Therefore, you must make sure that the port is properly
|
|
|
|
|
protected by a firewall.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li In the \gui {Run Settings}, \gui {Debugger Settings} section, select
|
2012-03-21 12:11:40 +01:00
|
|
|
the \gui {Enable QML} check box to enable
|
2011-09-27 11:52:34 +02:00
|
|
|
QML debugging.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Select \gui {Build > Rebuild Project} to clean and rebuild the
|
2011-09-27 11:52:34 +02:00
|
|
|
project.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To debug applications on devices, check that Qt 4.7.4, or later,
|
2012-01-09 11:04:29 +01:00
|
|
|
libraries are installed on the device and
|
2012-09-14 12:44:57 +02:00
|
|
|
\l{Running on Multiple Platforms}{select the corresponding kit for the device}
|
2012-01-09 11:04:29 +01:00
|
|
|
before you start debugging.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2012-01-09 11:04:29 +01:00
|
|
|
\endlist
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\section1 Mixed C++/QML Debugging
|
|
|
|
|
|
|
|
|
|
To debug both the C++ and QML parts of your application at the same time,
|
2012-03-21 12:11:40 +01:00
|
|
|
select the \gui {Enable C++} and \gui {Enable QML} checkboxes for both
|
|
|
|
|
languages in the \gui {Debugger Settings} section in the project
|
|
|
|
|
\gui{Run Settings}.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2012-01-09 11:04:29 +01:00
|
|
|
\image qtquick-debugging-settings.png
|
|
|
|
|
|
2011-09-27 11:52:34 +02:00
|
|
|
\section1 Starting QML Debugging
|
|
|
|
|
|
|
|
|
|
To start the application, choose \gui {Debug > Start Debugging >
|
|
|
|
|
Start Debugging} or press \key F5. Once the application starts running, it
|
|
|
|
|
behaves and performs as usual. You can then perform the following tasks:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Debug JavaScript functions
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Execute JavaScript expressions to get information about the state of
|
2012-01-09 11:04:29 +01:00
|
|
|
the application
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Change QML code and immediately see the changes at runtime
|
2012-01-09 11:04:29 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Inspect QML code and change it temporarily at runtime
|
2012-01-09 11:04:29 +01:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To debug already running applications:
|
|
|
|
|
|
|
|
|
|
\list 1
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-08-08 11:30:52 +02:00
|
|
|
\li Build the application by using the appropriate configuration
|
|
|
|
|
parameters (if you build the application with \QC, it automatically
|
|
|
|
|
uses the correct configuration):
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\li Qt Quick 1: \c {CONFIG+=declarative_debug}
|
|
|
|
|
|
|
|
|
|
\li Qt Quick 2: \c {CONFIG+=qml_debug}
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\li Start the application with the following arguments:
|
|
|
|
|
|
|
|
|
|
\c {qmljsdebugger=port:<port>[,host:<ip address>][,block]}
|
|
|
|
|
|
|
|
|
|
Where \c port (mandatory) specifies the debugging port,
|
|
|
|
|
\c {ip address} (optional) specifies the IP address of the host
|
|
|
|
|
where the application is running, and \c block (optional) prevents
|
|
|
|
|
the application from running until the debug client connects to the
|
|
|
|
|
server. This enables debugging from the start.
|
2012-01-09 11:04:29 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Select \gui {Debug > Start Debugging > Attach to QML Port}.
|
2012-01-09 11:04:29 +01:00
|
|
|
|
2013-08-08 11:30:52 +02:00
|
|
|
Choose the kit configured for the device where the application to
|
|
|
|
|
be debugged is running. The port number to use is displayed in the
|
|
|
|
|
standard output when the application starts.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\section1 Debugging JavaScript Functions
|
|
|
|
|
|
|
|
|
|
You can use the \QC \gui Debug mode to inspect the state of your
|
2012-01-09 11:04:29 +01:00
|
|
|
application while debugging. You can interact with the debugger by:
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li \l{Setting Breakpoints}{Setting breakpoints}
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li \l{Viewing Call Stack Trace}{Viewing call stack trace}
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li \l{Locals and Expressions}{Viewing locals and expressions}
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\section1 Executing JavaScript Expressions
|
|
|
|
|
|
|
|
|
|
When the application is interrupted by a breakpoint, you can use the
|
2013-03-05 10:02:14 +01:00
|
|
|
\gui {QML/JS Console} to execute JavaScript expressions in the current
|
|
|
|
|
context. To open it, choose \gui Window > \gui {Output Panes} > \gui {QML/JS Console}.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-05 10:02:14 +01:00
|
|
|
\image qml-script-console.png "QML/JS Console"
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-05 10:02:14 +01:00
|
|
|
For more information about using the console, see \l{QML/JS Console}.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
\section1 Applying QML Changes at Runtime
|
|
|
|
|
|
|
|
|
|
If you change property values or add properties in the code editor, the
|
2011-11-16 13:28:27 +01:00
|
|
|
debugger can update the properties in the running application when you save
|
2012-04-18 15:37:14 +02:00
|
|
|
the file. This is enabled by default. To disable it, click the
|
2011-09-27 11:52:34 +02:00
|
|
|
\inlineimage qml-observer-bar-reload.png "Apply Changes on Save button"
|
2012-04-18 15:37:14 +02:00
|
|
|
(\gui {Apply Changes on Save}) button on the toolbar.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-13 12:50:27 +01:00
|
|
|
When you change property values in the \gui {QML/JS Console} or in the
|
2012-09-27 15:13:25 +02:00
|
|
|
\gui {Locals and Expressions} view, they are immediately updated in the running
|
2012-01-09 11:04:29 +01:00
|
|
|
application, but not in the source code.
|
|
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\section1 Inspecting Items
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2012-09-27 15:13:25 +02:00
|
|
|
While the application is running, you can use the
|
2013-03-13 11:39:36 +01:00
|
|
|
\gui {Locals and Expressions} view to explore the QML item structure.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\image qml-observer-view.png "QML item tree"
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2012-09-27 15:13:25 +02:00
|
|
|
To keep the application visible while you interact with the debugger, click
|
2012-01-09 11:04:29 +01:00
|
|
|
\inlineimage qml-inspector-app-on-top.png
|
|
|
|
|
(\gui {Show Application on Top}).
|
|
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
You can view a QML item in \gui {Locals and Expressions} in the following
|
2012-09-27 15:13:25 +02:00
|
|
|
ways:
|
2012-01-09 11:04:29 +01:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\li Expand the item in the object tree.
|
2012-09-27 15:13:25 +02:00
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\li Select the item in the code editor.
|
2012-01-09 11:04:29 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Click
|
2012-01-09 11:04:29 +01:00
|
|
|
\inlineimage qml-inspector-select-button.png
|
2013-03-13 11:39:36 +01:00
|
|
|
(\gui Select) to activate selection mode and then click an item
|
2012-01-09 11:04:29 +01:00
|
|
|
in the running application.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To change property values temporarily, without editing the source,
|
|
|
|
|
double-click them and enter the new values. You can view the results in the
|
|
|
|
|
running application.
|
|
|
|
|
|
2012-09-27 15:13:25 +02:00
|
|
|
\section1 Inspecting User Interfaces
|
2012-01-09 11:04:29 +01:00
|
|
|
|
2012-09-27 15:13:25 +02:00
|
|
|
When you debug complex applications, you can jump to the position in code
|
2013-03-13 11:39:36 +01:00
|
|
|
where an item is defined or you can zoom into the user interface.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
When the \gui Select tool is enabled, you can click items in the running
|
2011-09-27 11:52:34 +02:00
|
|
|
application to jump to their definitions in the code. The properties of the
|
2013-03-13 11:39:36 +01:00
|
|
|
selected item are displayed in the \gui {Locals and Expressions} view.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
You can also right-click an item in the running application to view the
|
|
|
|
|
item hierarchy as a context menu.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
2013-03-13 11:39:36 +01:00
|
|
|
\image qml-observer-context-menu.png "QML item hierarchy"
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
To switch to the zoom mode, click the \gui Zoom button. Click in the
|
|
|
|
|
running application to zoom in. Right-click to open a context menu that
|
|
|
|
|
contains zoom controls.
|
|
|
|
|
|
2012-09-27 15:13:25 +02:00
|
|
|
To switch out of the selection or zoom mode, deselect the \gui Select or
|
|
|
|
|
\gui Zoom button.
|
2011-09-27 11:52:34 +02:00
|
|
|
|
|
|
|
|
To move the application running in \QQV to the front, select the
|
|
|
|
|
\gui {Show Application on Top} button.
|
|
|
|
|
|
|
|
|
|
*/
|