2012-01-05 16:11:09 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2012-01-05 16:11:09 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** This file is part of the Qt Creator documentation.
|
2012-01-05 16:11:09 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-01-05 16:11:09 +01:00
|
|
|
**
|
2016-01-15 14:51:16 +01:00
|
|
|
** GNU Free Documentation License Usage
|
2012-01-05 16:11:09 +01:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Free
|
|
|
|
|
** Documentation License version 1.3 as published by the Free Software
|
2016-01-15 14:51:16 +01:00
|
|
|
** Foundation and appearing in the file included in the packaging of
|
|
|
|
|
** this file. Please review the following information to ensure
|
|
|
|
|
** the GNU Free Documentation License version 1.3 requirements
|
|
|
|
|
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
|
2012-01-05 16:11:09 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// 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.
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
/*!
|
2014-03-17 12:18:12 +01:00
|
|
|
\contentspage {Qt Creator Manual}
|
2012-01-05 16:11:09 +01:00
|
|
|
\previouspage creator-debugging-example.html
|
|
|
|
|
\page creator-qml-debugging-example.html
|
2012-04-16 15:09:32 +02:00
|
|
|
\nextpage creator-troubleshooting-debugging.html
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\title Debugging a Qt Quick Example Application
|
|
|
|
|
|
|
|
|
|
This section uses the
|
2013-11-25 17:37:19 +01:00
|
|
|
\l{QML Advanced Tutorial}{Same Game}
|
2013-03-13 10:29:46 +01:00
|
|
|
example application to illustrate how to debug Qt Quick applications in the
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol Debug mode.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
For more information about all the options you have, see
|
|
|
|
|
\l{Debugging Qt Quick Projects}.
|
|
|
|
|
|
|
|
|
|
The Same Game demo shows how to write a game in QML, using JavaScript for
|
|
|
|
|
all the game logic. Open the demo project in \QC to debug it:
|
|
|
|
|
|
|
|
|
|
\list 1
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To look at the code that starts a new game, place a breakpoint in
|
2012-01-05 16:11:09 +01:00
|
|
|
samegame.qml by clicking between the line number and the window
|
|
|
|
|
border on the line where where the \c startNewGame() function is
|
2012-04-18 15:37:14 +02:00
|
|
|
called (1).
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\image qtquick-example-setting-breakpoint1.png
|
|
|
|
|
|
|
|
|
|
The red circle indicates that a breakpoint is now set on that line
|
|
|
|
|
number.
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select \uicontrol {Debug > Start Debugging > Start Debugging} or press
|
2012-01-05 16:11:09 +01:00
|
|
|
\key{F5}.
|
|
|
|
|
|
2016-04-28 14:57:25 +02:00
|
|
|
\li Once the Same Game application starts, select \uicontrol {1 Player}
|
|
|
|
|
to start a new game.
|
|
|
|
|
|
|
|
|
|
\image samegame.png
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li When the debugger hits the breakpoint, it interrupts the
|
2012-01-05 16:11:09 +01:00
|
|
|
application. \QC displays the nested function calls leading to the
|
2012-09-27 15:13:25 +02:00
|
|
|
current position as a call stack trace (1).
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\image qtquick-example-setting-breakpoint2.png
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Click the
|
2012-04-18 15:37:14 +02:00
|
|
|
\inlineimage qtcreator-debug-button-step-into.png
|
2014-12-11 15:43:19 +01:00
|
|
|
(\uicontrol {Step Into}) button on the toolbar or press \key F11 to step
|
2012-01-05 16:11:09 +01:00
|
|
|
into the code in the stack. The samegame.js file opens in the code
|
|
|
|
|
editor at the function that starts a new game.
|
|
|
|
|
|
|
|
|
|
\image qtquick-example-stack.png
|
|
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Examine the local variables in the \uicontrol {Locals and Expressions}
|
2012-01-05 16:11:09 +01:00
|
|
|
view. Step through the code to see how the information changes in
|
|
|
|
|
the view.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Add a breakpoint at the end of the \c {startNewGame()} function, and
|
2012-01-05 16:11:09 +01:00
|
|
|
click \inlineimage qtcreator-debugging-continue.png
|
2014-12-11 15:43:19 +01:00
|
|
|
(\uicontrol Continue) to hit the breakpoint.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\image qtquick-example-setting-breakpoint3.png
|
|
|
|
|
|
2013-03-13 12:50:27 +01:00
|
|
|
\li To execute JavaScript commands in the current context, open the
|
2015-11-10 16:59:02 +01:00
|
|
|
\uicontrol {Debugger Console} output pane.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2016-04-28 14:57:25 +02:00
|
|
|
\image qml-script-console.png
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To remove a breakpoint, right-click it and select
|
2014-12-11 15:43:19 +01:00
|
|
|
\uicontrol {Delete Breakpoint}.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2014-12-11 15:43:19 +01:00
|
|
|
\li Select the \uicontrol {Locals and Expressions} tab to explore the object
|
2012-09-27 15:13:25 +02:00
|
|
|
structure at runtime:
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\image qtquick-example-qml-inspector.png
|
|
|
|
|
|
2016-04-28 14:57:25 +02:00
|
|
|
\li Select \uicontrol Debug > \uicontrol {Show Application on Top} to
|
|
|
|
|
keep the application visible while you interact with the debugger.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2016-04-28 14:57:25 +02:00
|
|
|
\li Select \uicontrol Debug > \uicontrol Select to activate selection
|
|
|
|
|
mode and then click the \uicontrol Menu button to move into the
|
|
|
|
|
\uicontrol menuButton component in the
|
|
|
|
|
\uicontrol {Locals and Expressions} view and the code editor.
|
2013-03-13 12:50:27 +01:00
|
|
|
|
2016-04-28 14:57:25 +02:00
|
|
|
\li In the \uicontrol {Locals and Expressions} view, double-click the
|
|
|
|
|
value of a property to change it.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
*/
|