summaryrefslogtreecommitdiff
path: root/doc/src/debugger/qtquick-debugging.qdoc
blob: 63b5cf27f254ae17143c52b37b4cc819fe6afc24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/****************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
**
** 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
****************************************************************************/

// **********************************************************************
// 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
    \nextpage creator-troubleshooting-debugging.html

    \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
    Qt 4.7.4, or later, libraries on devices. To debug applications on Symbian
    devices, you must install also QML Viewer on them.

    \section1 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:

    \list 1

        \o  Select \gui Projects, and then select the \gui QML check box in the
            \gui {Run Settings}, to enable QML debugging.

        \o  Compile the QML Inspector debugging helper. For more information,
            see \l{Debugging Helpers for QML}.

    \endlist

    To debug Qt Quick Applications:

        \list 1

        \o  Select \gui Projects, and then select the
            \gui {Enable QML debugging} check box in the \gui qmake section
            in \gui {Build Steps}.

            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.

        \o  In the \gui {Run Settings}, select the \gui QML check box to enable
            QML debugging.

        \o  Select \gui {Build > Rebuild Project} to clean and rebuild the
            project.

    \endlist

    To debug Qt Quick Applications on devices, install Qt 4.7.4, or later,
    libraries on devices. Then select the device as the target before you
    start debugging.

    \section1 Mixed C++/QML Debugging

    To debug both the C++ and QML parts of your application at the same time,
    select the checkboxes for both languages in the \gui{Run Settings}. However,
    C++ breakpoints are be ignored until the debugger attaches also to the
    QML engine.

    \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

        \o  Debug JavaScript functions

        \o  Preview QML changes at runtime

        \o  Inspect QML at runtime

    \endlist

    \section1 Debugging JavaScript Functions

    You can use the \QC \gui Debug mode to inspect the state of your
    application while debugging. You can interact with the debugger in several
    ways, as described in the following sections:

    \list

        \o  \l{Setting Breakpoints}

        \o  \l{Viewing Call Stack Trace}

        \o  \l{Locals and Expressions}

    \endlist

    \section1 Executing JavaScript Expressions

    When the application is interrupted by a breakpoint, you can use the
    \gui {QML Script Console} to execute JavaScript expressions in the current
    context. To open it, choose \gui {Window > View > QML Script Console}.

    \image qml-script-console.png "QML Script Console view"

    You can type JavaScript expressions and use them to get information about
    the state or your application. For example, property values.

    You can see the current value of a property by hovering over it in the code
    editor.

    \section1 Applying QML Changes at Runtime

    If you change property values or add properties in the code editor, the
    changes are updated in the running application when you save them. If live
    preview is not supported for an element, a message appears. Click
    \gui Reload to preview the changes.

    Reloading is enabled by default. To disable it, click
    \inlineimage qml-observer-bar-reload.png "Apply Changes on Save button"
    on the toolbar.

    \section1 Inspecting QML at Runtime

    While the application is running, you can use the \gui {QML Inspector} view
    to explore the object structure, debug animations, and inspect colors.
    To open the \gui {QML Inspector} view, choose \gui {Window > View >
    QML Inspector}. The view shows the properties of the currently selected QML
    element.

    \image qml-observer-view.png "QML Inspector view"

    When you debug complex applications, you can use the inspection
    mode to jump to the position in code where an element is defined. You are
    switched to the inspection mode, when you click the \gui Select, \gui Zoom,
    or \gui {Color Picker} button
    on the toolbar.

    \image qml-observer-buttons.png "QML Inspector toolbar"

    When the \gui Select tool is enabled, you can click elements in the running
    application to jump to their definitions in the code. The properties of the
    selected element are displayed in the \gui {QML Inspector} view. The element
    hierarchy is displayed as a bread crumb path.

    You can also right-click an element in the running application to view the
    element hierarchy as a context menu.

    \image qml-observer-context-menu.png "QML Inspector"

    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.

    To inspect colors, click the \gui {Color Picker} button. You can also click
    \inlineimage qml-observer-bar-copy-color.png "Copy Color button"
    to copy the color definition to the clipboard.

    To switch out of the inspection mode, deselect the \gui Select, \gui Zoom,
    and \gui {Color Picker} button.

    To move the application running in \QQV to the front, select the
    \gui {Show Application on Top} button.

    \section1 Debugging Animations

    \image qml-observer.png

    To play and pause animations in the running application, select the
    \gui {Play/Pause Animations} button on the toolbar or \gui {Debugging >
    Animations > Pause}, or press
    \key {Ctrl+.}.

    To change the speed at which animations are played, select a value in
    \gui {Debugging > Animations} or click and hold down the
    \gui {Play/Pause Animations} button to select a value.

*/