2012-01-05 16:11:09 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (c) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2012-01-05 16:11:09 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator
|
2012-01-05 16:11:09 +01: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-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
|
2012-01-05 16:11:09 +01:00
|
|
|
\gui Debug mode.
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Select \gui {Debug > Start Debugging > Start Debugging} or press
|
2012-01-05 16:11:09 +01:00
|
|
|
\key{F5}.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Once the Same Game application starts, click the \gui {New Game}
|
2012-01-05 16:11:09 +01:00
|
|
|
button to start a new game.
|
|
|
|
|
|
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
|
2012-01-05 16:11:09 +01:00
|
|
|
(\gui {Step Into}) button on the toolbar or press \key F11 to step
|
|
|
|
|
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
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Examine the local variables in the \gui {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
|
|
|
|
|
(\gui Continue) to hit the breakpoint.
|
|
|
|
|
|
|
|
|
|
\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
|
|
|
|
|
\gui {QML/JS Console} output pane.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To change the score to 1000, enter \c{gameCanvas.score = 1000}
|
2012-01-05 16:11:09 +01:00
|
|
|
in the console.
|
|
|
|
|
|
|
|
|
|
\image qtquick-example-script-console.png
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li To remove a breakpoint, right-click it and select
|
2012-01-05 16:11:09 +01:00
|
|
|
\gui {Delete Breakpoint}.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Select the \gui {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
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Click
|
2012-01-05 16:11:09 +01:00
|
|
|
\inlineimage qml-inspector-app-on-top.png
|
|
|
|
|
(\gui {Show Application on Top}) to keep the application visible
|
|
|
|
|
while you interact with the debugger.
|
|
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li Click
|
2012-01-05 16:11:09 +01:00
|
|
|
\inlineimage qml-inspector-select-button.png
|
|
|
|
|
(\gui Select) to activate selection mode and then click the
|
2012-04-18 15:37:14 +02:00
|
|
|
\gui {Quit} button to move into the \gui ButtonLabel component
|
2013-03-13 12:50:27 +01:00
|
|
|
in the \gui {QML/JS Console} and the code editor.
|
2012-01-05 16:11:09 +01:00
|
|
|
|
2013-02-06 08:50:23 +01:00
|
|
|
\li In the \gui {Locals and Expressions} view, double-click the value of
|
2012-09-27 15:13:25 +02:00
|
|
|
the \c text property to change it temporarily from \gui {Quit} to
|
2012-01-05 16:11:09 +01:00
|
|
|
\gui {End Game}.
|
|
|
|
|
|
2013-03-13 12:50:27 +01:00
|
|
|
\image qtquick-example-property-values.png
|
|
|
|
|
|
2012-01-05 16:11:09 +01:00
|
|
|
When you select an element, the cursor moves to it in the code
|
|
|
|
|
editor, where you can change the value permanently.
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
*/
|