Newer
Older
\o In the \gui {Colors} section, click the color picker to select a red

Leena Miettinen
committed
color.
\o In the \gui {Radius} field, use the slider to set the radius value
to \bold 50.

Leena Miettinen
committed
\image qmldesigner-helloworld-widget-edit.png "Edit the component"

Leena Miettinen
committed
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
\endlist
\o To create a blue ball, press \key {Ctrl+C} and \key {Ctrl+V} to copy
and paste the red one, and then change its color to blue.
\image qmldesigner-helloworld-base-state.png "Hello World first view"
The first view of your application is now ready.
\note You can use graphical design tools to create nice images and
copy them to the projects folder to display them in the \gui {Library}
pane in \gui {Resources}.
\o In the \gui State pane, click the plus sign to add another view, or \e state
to the application.
\o Modify the state by dragging and dropping the widgets to switch their
places.
\image qmldesigner-helloworld-state1.png "Hello World second view"
\endlist
\section1 Animating the Scene
Animate the scene so that the widgets appear to switch places
on the screen.
\list 1
\o Click \gui {Edit} to open HelloWorld.qml in the code editor.
\o Add the following code to create a transition:
\code
transitions: [
Transition {
NumberAnimation { properties: "x, y"; duration: 500 }
}
\endcode
\note The code editor completes the code for you as you type.
\o Click the \inlineimage qtcreator-run.png
button to check that the application can be built and run.
\endlist
\section1 Adding Interaction
Add interaction to the scene to allow users to click on the screen to start
the animation.
\list 1
\o Click \gui{Design} to open HelloWorld.qml in the visual editor.
\o Drag and drop a \gui {Mouse Area} from the \gui {Library} to the scene.
\o In the \gui {Properties} pane, \gui {Geometry} tab, click the

Leena Miettinen
committed
\inlineimage qmldesigner-anchor-fill-screen.png
button to make the mouse region cover the whole screen.
\o In the code editor, use data binding to add a \c when statement to
the states sections, as illustrated by the following code:
\code
states: [
State {
name: "State1"
when: mousearea1.pressed
\endcode
\endlist

Leena Miettinen
committed
\section1 Building and Running the Application

Leena Miettinen
committed
\list 1
\o Press \key {Ctrl+R} to build and run the application.
\o Click the screen and keep the mouse button pressed down to run the
animation.
\endlist

Leena Miettinen
committed
\note In the \gui {QML Viewer}, select \gui {Skin} and select a mobile device
type to view the application as on a mobile device.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-build-example-application.html

Leena Miettinen
committed
\page creator-writing-program.html
\nextpage creator-mobile-example.html

Leena Miettinen
committed

Leena Miettinen
committed
\title Creating a Qt C++ Application
\note This tutorial assumes that you have experience in writing basic Qt

Leena Miettinen
committed
applications, using \QD to design user interfaces and using the Qt

Leena Miettinen
committed
This tutorial describes how to use Qt Creator
to create a small Qt application, Text Finder. It is a simplified version of the
QtUiTools \l{http://doc.qt.nokia.com/4.7-snapshot/uitools-textfinder.html}{Text Finder}

Leena Miettinen
committed
example.
\image qtcreator-textfinder-screenshot.png
\section1 Setting Up Your Environment

Leena Miettinen
committed
Qt Creator automatically detects whether the location of Qt is in your \c PATH variable.
If you have installed several Qt versions, follow the
instructions in \l{Selecting the Qt version} to set the Qt path.

Leena Miettinen
committed
\section1 Creating the Text Finder Project

Leena Miettinen
committed
\note Create the project with the \gui{Help} mode active so that you can follow
these instructions while you work.

Leena Miettinen
committed
\list 1
\o Select \gui{File > New File or Project > Qt Application Project > Qt Gui
Application > Choose}.

Leena Miettinen
committed

Leena Miettinen
committed
\image qtcreator-new-project.png "New File or Project dialog"

Leena Miettinen
committed

Leena Miettinen
committed
The \gui{Introduction and Project Location} dialog opens.

Leena Miettinen
committed

Leena Miettinen
committed
\image qtcreator-intro-and-location.png "Introduction and Project Location dialog"

Leena Miettinen
committed

Leena Miettinen
committed
\o In the \gui{Name} field, type \bold {TextFinder}.
\o In the \gui {Create in} field, enter the path for the project files. For example,
\c {C:\Qt\examples}, and then click \gui{Next}.

Leena Miettinen
committed

Leena Miettinen
committed
The \gui{Select Required Qt Versions} dialog opens.
\image qtcreator-new-project-qt-versions.png "Select Required Qt Versions dialog"

Leena Miettinen
committed
\o Click \gui{Next} to use the Qt version set in the path in your project.

Leena Miettinen
committed
The \gui{Class Information} dialog opens.

Leena Miettinen
committed
\image qtcreator-class-info.png "Class Information dialog"

Leena Miettinen
committed
\o In the \gui{Class Name} field, type \bold {TextFinder} as the class name.

Leena Miettinen
committed
\o In the \gui{Base Class} list, select \bold {QWidget} as the base class type.

Leena Miettinen
committed
\note The \gui{Header File}, \gui{Source File} and
\gui{Form File} fields are automatically updated to match the name of the
class.

Leena Miettinen
committed
\o Click \gui{Next}.

Leena Miettinen
committed
The \gui{Project Management} dialog opens.

Leena Miettinen
committed
\image qtcreator-new-project-summary.png "Project Management dialog"

Leena Miettinen
committed

Leena Miettinen
committed
\o Review the project settings, and click \gui{Finish} to create the project.

Leena Miettinen
committed

Leena Miettinen
committed
\endlist

Leena Miettinen
committed

Leena Miettinen
committed
The TextFinder project now contains the following files:

Leena Miettinen
committed
\o textfinder.h
\o textfinder.cpp
\o main.cpp
\o textfinder.ui
\o textfinder.pro

Kavindra Devi Palaraja
committed

Leena Miettinen
committed
\image qtcreator-textfinder-contents.png "TextFinder project contents"

Leena Miettinen
committed
The .h and .cpp files come with the necessary boiler plate code.
The .pro file is complete.

Leena Miettinen
committed
Begin by designing the user interface and then move on to filling
in the missing code. Finally, add the find functionality.

Leena Miettinen
committed
\section2 Designing the User Interface

Leena Miettinen
committed
\image qtcreator-textfinder-ui.png "Text Finder UI"

Leena Miettinen
committed
\list 1

Leena Miettinen
committed
\o In the \gui{Editor} mode, double-click the textfinder.ui file in the \gui{Projects}
view to launch the integrated \QD.

Leena Miettinen
committed
\o Drag and drop the following widgets to the form:
\o \gui{Label} (\l{http://doc.qt.nokia.com/4.7-snapshot/qlabel.html}{QLabel})
\o \gui{Line Edit} (\l{http://doc.qt.nokia.com/4.7-snapshot/qlineedit.html}{QLineEdit})
\o \gui{Push Button} (\l{http://doc.qt.nokia.com/4.7-snapshot/qpushbutton.html}{QPushButton})

Leena Miettinen
committed

Leena Miettinen
committed
\image qtcreator-textfinder-ui-widgets.png "Adding widgets to Text Finder UI"

Leena Miettinen
committed
\o Double-click the \gui{Label} widget and enter the text \bold{Keyword}.
\o Double-click the \gui{Push Button} widget and enter the text \bold{Find}.

Leena Miettinen
committed
\o In the \gui Properties pane, change the \gui objectName to \bold findButton.
\image qtcreator-textfinder-objectname.png "Changing object names"

Leena Miettinen
committed
\o Press \key {Ctrl+A} to select the widgets and click \gui{Lay out Horizontally}
(or press \gui{Ctrl+H}) to apply a horizontal layout
(\l{http://doc.qt.nokia.com/4.7-snapshot/qhboxlayout.html}{QHBoxLayout}).

Leena Miettinen
committed
\image qtcreator-texfinder-ui-horizontal-layout.png "Applying horizontal layout"

Leena Miettinen
committed
\o Drag and drop a \gui{Text Edit} widget (\l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html}{QTextEdit})

Leena Miettinen
committed
to the form.

Leena Miettinen
committed
\o Select the screen area and click \gui{Lay out Vertically} (or press \gui{Ctr+V})
to apply a vertical layout (\l{http://doc.qt.nokia.com/4.7-snapshot/qvboxlayout.html}{QVBoxLayout}).

Leena Miettinen
committed
\image qtcreator-textfinder-ui.png "Text Finder UI"

Leena Miettinen
committed

Leena Miettinen
committed
Applying the horizontal and vertical layouts ensures that the application UI scales to different
screen sizes.
\o To call a find function when users press the \gui Find button, you use the Qt signals
and slots mechanism. A signal is emitted when a particular event occurs and a slot is
a function that is called in response to a particular signal. Qt widgets have predefined
signals and slots that you can use directly from \QD. To add a slot for the find function:
\list
\o Right-click the \gui Find button to open a context-menu.
\o Select \gui {Go to Slot > clicked()}, and then select \gui OK.
A private slot, \c{on_findButton_clicked()}, is added to the header file,
textfinder.h and a private function, \c{TextFinder::on_findButton_clicked()},
is added to the source file, textfinder.cpp.
\endlist

Leena Miettinen
committed
\o Press \gui{Ctrl+S} to save your changes.

Leena Miettinen
committed
For more information about designing forms with \QD, see the
\l{http://doc.qt.nokia.com/4.7-snapshot/designer-manual.html}{Qt Designer Manual}.

Leena Miettinen
committed
\section2 Completing the Header File

Leena Miettinen
committed
The textfinder.h file already has the necessary #includes, a

Leena Miettinen
committed
constructor, a destructor, and the \c{Ui} object. You need to add a private

Leena Miettinen
committed
function, \c{loadTextFile()}, to read and display the

Leena Miettinen
committed
contents of the input text file in the
\l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html}{QTextEdit}.

Leena Miettinen
committed
\list 1
\o In the \gui{Projects} view, double-click the \c{textfinder.h} file
to open it for editing.

Leena Miettinen
committed
\o Add a private function
to the \c{private} section, after the \c{Ui::TextFinder} function, as

Leena Miettinen
committed
illustrated by the following code snippet:

Kavindra Devi Palaraja
committed
\snippet examples/textfinder/textfinder.h 0

Leena Miettinen
committed
\endlist

Leena Miettinen
committed
\section2 Completing the Source File

Leena Miettinen
committed
Now that the header file is complete, move on to the source file,

Leena Miettinen
committed
textfinder.cpp.

Leena Miettinen
committed
\list 1

Leena Miettinen
committed
\o In the \gui{Projects} view, double-click the textfinder.cpp file

Leena Miettinen
committed
to open it for editing.

Leena Miettinen
committed
\o Add code to load a text file using
\l{http://doc.qt.nokia.com/4.7-snapshot/qfile.html}{QFile}, read it with
\l{http://doc.qt.nokia.com/4.7-snapshot/qtextstream.html}{QTextStream}, and
then display it on \c{textEdit} with
\l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html#plainText-prop}{setPlainText()}.

Leena Miettinen
committed
This is illustrated by the following code snippet:
\snippet examples/textfinder/textfinder.cpp 0
\o To use \l{http://doc.qt.nokia.com/4.7-snapshot/qfile.html}{QFile} and
\l{http://doc.qt.nokia.com/4.7-snapshot/qtextstream.html}{QTextStream}, add the

Leena Miettinen
committed
following #includes to textfinder.cpp:

Kavindra Devi Palaraja
committed
\snippet examples/textfinder/textfinder.cpp 1

Leena Miettinen
committed
\o For the \c{on_findButton_clicked()} slot, add code to extract the search string and
use the \l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html#find}{find()} function

Leena Miettinen
committed
to look for the search string within the text file. This is illustrated by
the following code snippet:

Kavindra Devi Palaraja
committed
\snippet examples/textfinder/textfinder.cpp 2

Leena Miettinen
committed
\o Once both of these functions are complete, add a line to call \c{loadTextFile()} in
the constructor, as illustrated by the following code snippet:

Kavindra Devi Palaraja
committed
\snippet examples/textfinder/textfinder.cpp 3

Leena Miettinen
committed
\endlist
The \c{on_findButton_clicked()} slot is called automatically in

Leena Miettinen
committed
the uic generated ui_textfinder.h file by this line of code:
QMetaObject::connectSlotsByName(TextFinder);

Leena Miettinen
committed
\section2 Creating a Resource File

Leena Miettinen
committed
You need a resource file (.qrc) within which you embed the input
text file. The input file can be any .txt file with a paragraph of text.
Create a text file called input.txt and store it in the textfinder

Leena Miettinen
committed
folder.
\o Select \gui{File > New File or Project > Qt > Qt Resource File > Choose}.

Leena Miettinen
committed
\image qtcreator-add-resource-wizard.png "New File or Project dialog"

Leena Miettinen
committed
The \gui {Choose the Location} dialog opens.

Leena Miettinen
committed
\image qtcreator-add-resource-wizard2.png "Choose the Location dialog"

Leena Miettinen
committed
\o In the \gui{Name} field, enter \bold{textfinder}.
\o In the \gui{Path} field, enter \c{C:\Qt\examples\TextFinder},
and click \gui{Next}.

Leena Miettinen
committed
The \gui{Project Management} dialog opens.

Leena Miettinen
committed
\image qtcreator-add-resource-wizard3.png "Project Management dialog"

Leena Miettinen
committed
\o In the \gui{Add to project} field, select \bold{TextFinder.pro}

Leena Miettinen
committed
and click \gui{Finish} to open the file in the code editor.

Leena Miettinen
committed
\o Select \gui{Add > Add Prefix}.

Leena Miettinen
committed
\o In the \gui{Prefix} field, replace the default prefix with a slash (/).
\o Select \gui{Add > Add Files}, to locate and add input.txt.
\image qtcreator-add-resource.png "Editing resource files"
Now that you have all the necessary files, click the \inlineimage qtcreator-run.png
button to compile your program.

Kavindra Devi Palaraja
committed
\previouspage creator-maemo-emulator.html

Kavindra Palaraja
committed
\page creator-version-control.html

Kavindra Palaraja
committed

Kavindra Palaraja
committed
Version control systems supported by Qt Creator are:

Kavindra Palaraja
committed
\table
\header
\i \bold{Version Control System}
\i \bold{Address}
\i \bold{Notes}

Kavindra Palaraja
committed
\row
\i \bold{Git}

Kavindra Palaraja
committed
\i \l{http://git-scm.com/}

Kavindra Palaraja
committed
\row
\i \bold{Subversion}
\i \l{http://subversion.tigris.org/}

Kavindra Palaraja
committed
\row
\i \bold{Perforce}
\i \l{http://www.perforce.com}
\row
\i \bold{CVS}
\i \l{http://www.cvshome.org}
\i

Rohan Shetty
committed
\row
\i \bold{Mercurial}
\i \l{http://mercurial.selenic.com/}
\i Qt Creator 2.0 and later

Kavindra Palaraja
committed
\endtable

Kavindra Palaraja
committed
Qt Creator uses the version control system's command line clients to access
your repositories. To allow access, make sure that the command line clients

Leena Miettinen
committed
can be located using the \c{PATH} environment variable or specify the path to
the command line client executables in \gui{Tools} > \gui{Options...} >
\gui {Version Control}.
After you set up the version control system, use the command line to check
that everything works (for example, use the status command). If no issues arise,
you should be ready to use the system also from Qt Creator.
\section1 Setting Up Common Options
Select \gui{Tools} > \gui{Options...} > \gui{Version Control} > \gui{Common}
to specify settings for submit messages:
\o \gui{Submit message check script} is a script or program that
can be used to perform checks on the submit message before
submitting. The submit message is passed in as the script's first
parameter. If there is an error, the script should output a
message on standard error and return a non-zero exit code.
\o \gui{User/alias configuration file} takes a file in mailmap format
that lists user names and aliases. For example:
\code
Jon Doe <Jon.Doe@company.com>
Hans Mustermann <Hans.Mustermann@company.com> hm <info@company.com>
\endcode
\note The second line above specifies the alias \e{hm} and the
corresponding email address for \e{Hans Mustermann}. If the
user/alias configuration file is present, the submit editor
displays a context menu with \gui{Insert name...} that pops up a
dialog letting the user select a name.
\o \gui{User fields configuration file} is a simple text file
consisting of lines specifying submit message fields that take
user names, for example:
\code
Reviewed-by:
Signed-off-by:
\endcode
\endlist

Kavindra Palaraja
committed
The fields above appear below the submit message. They provide completion
for the aliases/public user names specified in the
\e{User/alias configuration file} as well as a button that opens the
aforementioned user name dialog.

Kavindra Palaraja
committed

Leena Miettinen
committed
\section1 Creating VCS Repositories for New Projects
Qt Creator allows for creating VCS repositories for version
control systems that support local repository creation, such as
Git or Mercurial.

Leena Miettinen
committed
When creating a new project by selecting \gui File >
\gui{New File or Project...}, you can choose a version
control system in the final wizard page.

Kavindra Palaraja
committed
The \gui{Tools} menu contains a sub-menu for each supported version
control system.
The \gui{Version Control} output pane displays the commands
that are executed, a timestamp, and the relevant output.
Select \gui {Window > Output Panes > Version Control} to open
the pane.

Leena Miettinen
committed
\image qtcreator-vcs-pane.png

Leena Miettinen
committed
\section2 Adding Files
When you create a new file or a new project, the wizard displays a page
asking whether the files should be added to a version control system.
This happens when the parent directory or the project is already
under version control and the system supports the concept of adding files,
for example, Perforce and Subversion. Alternatively, you can
add files later by using the version control tool menus.
With Git, there is no concept of adding files. Instead, all modified
files must be staged for a commit.
\section2 Viewing Diff Output
All version control systems provide menu options to \e{diff} the current
file or project: to compare it with the latest version stored in the
repository and to display the differences. In Qt Creator, a diff is
displayed in a read-only editor. If the file is accessible, you can
double-click on a selected diff chunk and Qt Creator opens an editor
displaying the file, scrolled to the line in question.
\image qtcreator-vcs-diff.png

Leena Miettinen
committed
\section2 Viewing Versioning History and Change Details
Display the versioning history of a file by selecting \gui{Log}
(for Git and Mercurial) or \gui{Filelog} (for CVS, Perforce, and
Subversion). Typically, the log output contains the date, the commit

Leena Miettinen
committed
message, and a change or revision identifier. Click on the identifier to
display a description of the change including the diff.
Right-clicking on an identifier brings up a context menu that lets you
show annotation views of previous versions (see \l{Annotating Files}).
\image qtcreator-vcs-log.png
\section2 Annotating Files
Annotation views are obtained by selecting \gui{Annotate} or \gui{Blame}.
Selecting \gui{Annotate} or \gui{Blame} displays the lines of the file
prepended by the change identifier they originate from. Clicking on the

Leena Miettinen
committed
change identifier shows a detailed description of the change.

Leena Miettinen
committed
To show the annotation of a previous version, right-click on the
version identifier at the beginning of a line and choose one of the
revisions shown at the bottom of the context menu. This allows you to
navigate through the history of the file and obtain previous versions of
it. It also works for Git and Mercurial using SHA's.

Leena Miettinen
committed
The same context menu is available when right-clicking on a version
identifier in the file log view of a single file.
Once you have finished making changes, submit them to the version control
system by choosing \gui{Commit} or \gui{Submit}. Qt Creator displays a
commit page containing a text editor where you can enter your commit
message and a checkable list of modified files to be included.
\image qtcreator-vcs-commit.png
When you have finished filling out the commit page information, click on
\gui{Commit} to start committing.
The \gui{Diff Selected Files} button brings up a diff view of the
files selected in the file list. Since the commit page is just another
editor, you can go back to it by closing the diff view. You can also check
a diff view from the editor combo box showing the \gui{Opened files}.
\section2 Reverting Changes
To discard local changes to a file or project, use the \gui Revert
function or the \gui {Undo Changes/Undo Repository Changes} function
(for Git). The changes discarded depend on the version control system.
For example, in Perforce, select \gui{Revert File/Revert Project}
to discard changes made to open files, reverting them to the
revisions last synchronized from the repository. Select
\gui{Revert Unchanged} to revert files if their contents or file
type have not changed after they were opened for editing.
\section2 Using Additional Git Functions
The \gui Git sub-menu contains the following additional items:
\row
\i \gui {Apply Patch/Apply Patch...}
\i Apply changes to a file or project from a diff file. You can
either apply a patch file that is open in Qt Creator or select
the patch file to apply from the file system.

Leena Miettinen
committed
\row

Leena Miettinen
committed
\i \gui{Stash Snapshot...}
\i Save a snapshot of your current

Leena Miettinen
committed
work under a name for later reference. For example, if you
want to try out something and find out later that it does not work,
you can discard it and return to the state of the snapshot.
\i Stash local changes prior to executing a \gui{Pull}.
\row
\i \gui{Stash Pop}
\i Remove a single stashed state from the stash list and apply it on
top of the current working tree state.
\i \gui{Pull}
\i Pull changes from the remote repository. If there are locally
modified files, you are prompted to stash those changes.
The \gui Git options page contains an option to do

Leena Miettinen
committed
a rebase operation while pulling.
\row

Leena Miettinen
committed
\i \gui{Clean Repository.../Clean Project...}

Leena Miettinen
committed
\i Collect all files that are not under version control
with the exception of patches and project files
and show them as a checkable list in a dialog
prompting for deletion. This lets you completely clean a build.
\row
\i \gui{Branches...}
\i Displays the branch dialog showing the local branches at the
top and remote branches at the bottom. To switch to the local
branch, double-click on it. Double-clicking on a remote
branch first creates a local branch with the same name that
tracks the remote branch, and then switches to it.
\image qtcreator-vcs-gitbranch.png

Leena Miettinen
committed
\row
\i \gui{Stashes...}
\i Displays a dialog showing the stashes created by

Leena Miettinen
committed
\gui{Stash Snapshot...} with options to restore,

Leena Miettinen
committed
display or delete them.
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
\row
\i \gui {Stage File for Commit}
\i Mark new or modified files for committing to the repository.
To undo this function, select \gui {Unstage File from Commit}.
\row
\i \gui{Show Commit...}
\i Select a commit to view. Enter the SHA of the commit
in the \gui Change field.
\endtable
\section2 Using Additional Mercurial Functions
The \gui Mercurial sub-menu contains the following additional items:
\table
\row
\i \gui{Import}
\i Apply changes from a patch file.
\row
\i \gui{Incoming}
\i Monitor the status of a remote repository by listing
the changes that will be pulled.
\row
\i \gui{Outgoing}
\i Monitor the status of a remote repository by listing
the changes that will be pushed.
\row
\i \gui{Pull}
\i Pull changes from the remote repository.
\row
\i \gui{Update}
\i Look at an earlier version of the code.
\endtable
\section2 Using Additional Perforce Functions
When you start Qt Creator, it looks for the executable specified
in the \gui{P4 command} field in \gui{Tools > Options... > Version
Control > Perforce}. If you do not use Perforce and want to turn
off the check, clear this field.
The \gui Perforce sub-menu contains the following additional items:
\table
\row
\i \gui{Describe...}
\i View information about changelists and the files in them.
\row
\i \gui{Edit File}
\i Open a file for editing.
\row
\i \gui{Opened}
\i List files that are open for editing.
\row
\i \gui{Pending Changes...}
\i Group files for commit.
\row
\i \gui{Update All/Update Current Project}
\i Fetch the current version of the current project or all
projects from the repository.
\section2 Using Additional Subversion Functions
The \gui Subversion sub-menu contains the following additional items:
\table
\row
\i \gui{Describe...}
\i Display commit log messages for a revision.
\row
\i \gui{Update Project/Update Repository}
\i Update your working copy.
\endtable
/*!
\contentspage index.html
\previouspage creator-editor-refactoring.html
\page creator-editor-locator.html

Leena Miettinen
committed
\nextpage creator-editor-codepasting.html
The locator provides one of the easiest ways in Qt Creator to browse
through projects, files, classes, methods, documentation and file systems.
You can find the locator in the bottom left of the Qt Creator window.
To activate the locator, press \key Ctrl+K (\key Cmd+K on Mac OS
X) or select \gui Tools > \gui Locate....
\image qtcreator-locator.png
To edit the currently open project's main.cpp file using the locator:

Rohan Shetty
committed
\o Enter \tt{main.cpp}.
It is also possible to enter only a part of a search string.
As you type, the locator shows the occurrences of that string regardless

Leena Miettinen
committed
of where in the name of an component it appears.
To narrow down the search results, you can use the following wildcard
characters:
\list

Rohan Shetty
committed
\o To match any number of any or no characters, enter \bold{*}.
\o To match a single instance of any character, enter \bold{?}.
The \gui Locator allows you to browse not only files, but any items
defined by \bold{locator filters}. By default, the locator contains
filters which locate:
\list

Rohan Shetty
committed
\o Files anywhere on your file system
\o Files belonging to your project, such as source, header resource,
and .ui files
\o Class and method definitions in your project or anywhere referenced
from your project
\o Help topics, including Qt documentation
\o Specific line in the document displayed in your editor
\endlist
To use a specific locator filter, type the assigned prefix followed by
\key Space. The prefix is usually a single character.
\l{http://doc.qt.nokia.com/4.7-snapshot/qdatastream.html}{QDataStream:}
\list 1
\o Activate the locator.
\o Enter \tt{\bold{: QDataStream}} (: (colon) followed by a
\key Space and the symbol name (QDataStream)).
By default the following filters are enabled and you do not need to use
their prefixes explicitly:
\list
\o Going to a line in the current file (l).
\o Going to an open file (o).
\o Going to a file in any open project (a).
\section2 Using the Default Locator Filters
The following locator filters are available by default:
\table
\header
\o Function
\row
\o Go to a line in the current file.
\o \tt{\bold{l \e{Line number}}}
\o \image qtcreator-locator-line.png
\row
\o \image qtcreator-locator-symbols.png
\row
\o \image qtcreator-locator-help.png
\row
\o Go to an open file.
\o \tt{\bold{o \e{File name}}}
\o \image qtcreator-locator-opendocs.png
\row
\o Go to a file in the file system (browse the file system).
\o \image qtcreator-locator-filesystem.png
\row
\o Go to a file in any project currently open.
\o \tt{\bold{a \e{File name}}}
\o \image qtcreator-locator-files.png
\row
\o \image qtcreator-locator-current-project.png
\row
\o \image qtcreator-locator-classes.png
\row
\o \image qtcreator-locator-methods.png
\endtable
To quickly access files not directly mentioned in your project, you can
create your own locator filters. That way you can locate files in a
directory structure you have defined.
To create a locator filter:
\list 1
\o In the locator, click \inlineimage qtcreator-locator-magnify.png
and select \gui Configure.... to open the \gui Locator options.
\o Click \gui Add.
\o In the \gui{Filter Configuration} dialog:
\list
\o Name your filter.
\o Select at least one directory. The locator searches directories
recursively.
\o Define the file pattern as a comma separated list. For example,

Rohan Shetty
committed
to search all .h and .cpp files, enter \bold{*.h,*.cpp}
\o Specify the prefix string.
To show only results matching this filter, select
\gui{Limit to prefix}.
\image qtcreator-navigate-customfilter.png
\endlist
\o Click OK.
\endlist
\section3 Configuring the Locator Cache
The locator searches the files matching your file pattern in the
directories you have selected and caches that information. The cache for
all default filters is updated as you write your code. By default,
Qt Creator updates the filters created by you once an hour.
To update the cached information manually, click
\inlineimage qtcreator-locator-magnify.png
and select \gui Refresh.
To set a new cache update time:
\list 1
\o Select \gui Tools > \gui Options... > \gui Locator.
\o In \gui{Refresh interval}, define new time in minutes.
*/

Kavindra Devi Palaraja
committed
/*!
\contentspage index.html

Leena Miettinen
committed
\previouspage creator-developing-symbian.html
\nextpage creator-editor-using.html

Kavindra Devi Palaraja
committed

Kavindra Devi Palaraja
committed
When you exit Qt Creator, a snapshot of your current workspace is stored
as a session.
A session is a collection of:

Kavindra Devi Palaraja
committed
\list
\o Open projects with their dependencies
\o Open editors
\o Breakpoints and watches
\o Bookmarks

Kavindra Devi Palaraja
committed
\endlist
If you work on a project and need to switch to another project for a
while, you can save your workspace as a session. This makes it easier
to return to working on the first project later.

Leena Miettinen
committed
To create a new session or remove existing sessions, select \gui File >
\gui Sessions > \gui{Session Manager}.
To switch between sessions, choose
\gui File > \gui Session. If you do not create or select a session,
Qt Creator always uses the default session, which was created the
last time you exited Qt Creator.
When you launch Qt Creator, a list of existing sessions is displayed on the
\gui{Welcome screen}.
\image qtcreator-welcome-session.png

Kavindra Devi Palaraja
committed
*/
\previouspage creator-build-dependencies.html
\nextpage creator-debugging-cpp.html
You can use the Qt Creator \gui Debug mode to inspect the state of your
Qt
\if defined(qtquick)
and Qt Quick
\endif

Leena Miettinen
committed
projects while debugging.

Leena Miettinen
committed
Qt Creator does not include a debugger. It provides a debugger plugin that acts
as an interface between the Qt Creator core and external native debuggers
such as the GNU Symbolic Debugger (gdb), the Microsoft Console Debugger (CDB),
and an internal Java Script debugger. You can use the native debuggers to
debug the C++ language.
\image qtcreator-debugger-views.png "Native debugger views"

Leena Miettinen
committed
\if defined(qtquick)
Qt Creator includes a QML inspector plugin that you can use to debug QML.
\image qmldesigner-inspector.png "QML inspector views"
When you start debugging, the appropriate tool is automatically selected depending
on the type of the project. If you only develop one kind of projects, you can turn
off this automation in \gui {Tools > Options... > Debugger > General}. Deselect the
\gui {Change debugger language automatically} check box.
The choice of language also determines the contents of the \gui Debug menu.
The \gui {Start Debugging > Start Debugging} command starts debugging by using the
tool appropriate for the project type. The availability of the other commands depends
on whether \gui C++ or \gui QML is selected in \gui {Debug > Language}.
You can create Qt Quick projects that contain C++ plugins or Qt projects that contain
QML content. While debugging such projects, you can switch between the native
debuggers and the QML inspector during debugging.
To switch between debugged languages, select \gui {Debug > Language > C++} or
\gui QML. You can also press \key {Ctrl+L, 1} to switch to the native debugger and
\key {Ctrl+L, 2} to switch to the QML inspector.

Leena Miettinen
committed
\endif
\contentspage index.html
\previouspage creator-debugging-helpers.html
\page creator-debugging-qml.html
\nextpage creator-qml-inspector.html
\title Debugging Qt Quick Applications
In the \gui Debug mode you can use the QML inspector plugin to:
\list
\o View the status of the application when it is executed.
\o View debug output.
\o Write JavaScript expressions and evaluate them.
\o Modify the values of properties.