Skip to content
Snippets Groups Projects
qtcreator.qdoc 253 KiB
Newer Older
    This tutorial describes how to use Qt Creator to create a small
    \image qmldesigner-helloworld-edited.png "Hello World"
        \o Select \gui{File > New File or Project > Qt Quick Project > Qt QML Application > Choose}.

        \image qmldesigner-new-project.png "New File or Project dialog"

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

        \image qmldesigner-new-project-location.png "Introduction and Project Location dialog"

        \o In the \gui{Name} field, type \bold {HelloWorld}.

        \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}.

        The \gui{Project Management} dialog opens.

        \image qmldesigner-new-project-summary.png "Project Management dialog"

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

    \endlist

    The HelloWorld project now contains the following files:

    \list
        \o HelloWorld.qmlproject
        \o HelloWorld.qml
    \endlist

    The \gui Projects pane in the \gui Sidebar displays the project files:

    \image qmldesigner-new-project-contents.png "HelloWorld project contents"

    The .qmlproject file defines that all QML, JavaScript, and image files in
    the project folder belong to the project.
    The .qml file contains the following example code that specifies a rectangle
    and a label that contains
    the text \bold {Hello World}.
    Rectangle {
        width: 200
        height: 200
        Text {
            x: 66
            y: 93
            text: "Hello World"
        }
    }
    \section1 Running the Application
    Press \key {Ctrl+R} to run the application in the QML Viewer.
    \image qmldesigner-helloworld.png "Hello World"
    \section1 Changing Hello World Properties
    To experiment with QML and to try some of the code editor features, change the
    properties of the rectangle and text. Move the cursor on \gui Rectangle and
    press \key F1 to get help on the available properties. Try adding a \gui color
    property to the \gui Rectangle. When you start to type,
    the code completion feature of the code editor suggests properties, IDs, and
    code snippets to complete the code. Select an item in the list and press
    \key Tab or \key Enter to complete the code.
    The code editor checks the code syntax and underlines syntax errors.
    Move the cursor over an error to display detailed information about it.
    The following code illustrates how to set the backround color
    to light steel blue and the text color to white:
    import Qt 4.7

    Rectangle {
        width: 200
        height: 200
        color: "lightsteelblue"
        Text {
            x: 66
            y: 93
            text: "Hello World"
            color: "white"
        }
    }
    \image qmldesigner-helloworld-edited.png "Hello World in blue and white"
    \previouspage creator-build-example-application.html
    \nextpage creator-mobile-example.html
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \note This tutorial assumes that you have experience in writing basic Qt
    applications, using \QD to design user interfaces and using the Qt
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    Resource System.
con's avatar
con 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}
con's avatar
con committed

    \image qtcreator-textfinder-screenshot.png

    \section1 Setting Up Your Environment

    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.
con's avatar
con committed

    \section1 Creating the Text Finder Project
con's avatar
con committed

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

    \list 1

        \o Select \gui{File > New File or Project > Qt Application Project > Qt Gui
           \image qtcreator-new-project.png "New File or Project dialog"
        The \gui{Introduction and Project Location} dialog opens.
        \image qtcreator-intro-and-location.png "Introduction and Project Location dialog"
        \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}.
        The \gui{Select Required Qt Versions} dialog opens.

        \image qtcreator-new-project-qt-versions.png "Select Required Qt Versions dialog"

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

        The \gui{Class Information} dialog opens.
con's avatar
con committed

        \image qtcreator-class-info.png "Class Information dialog"
con's avatar
con committed

        \o In the \gui{Class Name} field, type \bold {TextFinder} as the class name.
con's avatar
con committed

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

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

        \image qtcreator-new-project-summary.png "Project Management dialog"
        \o Review the project settings, and click \gui{Finish} to create the project.


    The TextFinder project now contains the following files:
con's avatar
con committed

    \list
        \o textfinder.h
        \o textfinder.cpp
        \o main.cpp
        \o textfinder.ui
        \o textfinder.pro
con's avatar
con committed
    \endlist
    \image qtcreator-textfinder-contents.png "TextFinder project contents"

    The .h and .cpp files come with the necessary boiler plate code.
    The .pro file is complete.
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section1 Filling in the Missing Pieces
con's avatar
con committed

    Begin by designing the user interface and then move on to filling
    in the missing code. Finally, add the find functionality.
con's avatar
con committed

con's avatar
con committed

    \image qtcreator-textfinder-ui.png "Text Finder UI"
con's avatar
con committed

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

    \o Drag and drop the following widgets to the form:
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \list
    \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})
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist

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

    \note To easily locate the widgets, use the search box at the top of the
    \gui Sidebar. For example, to find the \gui Label widget, start typing
    the word \bold label.

    \image qtcreator-texfinder-filter.png "Filter field"

    \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}.
con's avatar
con committed

    \o In the \gui Properties pane, change the \gui objectName to \bold findButton.

    \image qtcreator-textfinder-objectname.png "Changing object names"

    \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}).

    \image qtcreator-texfinder-ui-horizontal-layout.png "Applying horizontal layout"
    \o Drag and drop a \gui{Text Edit} widget (\l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html}{QTextEdit})
    \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}).

    \image qtcreator-textfinder-ui.png "Text Finder UI"
    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

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist

    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}.
con's avatar
con committed

con's avatar
con committed

    The textfinder.h file already has the necessary #includes, a
    constructor, a destructor, and the \c{Ui} object. You need to add a private
    function, \c{loadTextFile()}, to read and display the
    \l{http://doc.qt.nokia.com/4.7-snapshot/qtextedit.html}{QTextEdit}.

    \list 1

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

    \o Add a private function
    to the \c{private} section, after the \c{Ui::TextFinder} function, as
    illustrated by the following code snippet:
con's avatar
con committed

    \snippet examples/textfinder/textfinder.h 0
con's avatar
con committed

con's avatar
con committed

    Now that the header file is complete, move on to the source file,
con's avatar
con committed

    \o In the \gui{Projects} view, double-click the textfinder.cpp file
con's avatar
con committed

    \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()}.
    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

    \snippet examples/textfinder/textfinder.cpp 1
con's avatar
con 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
    to look for the search string within the text file. This is illustrated by
    the following code snippet:
con's avatar
con committed

    \snippet examples/textfinder/textfinder.cpp 2
con's avatar
con 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:
con's avatar
con committed

    \snippet examples/textfinder/textfinder.cpp 3
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    The \c{on_findButton_clicked()} slot is called automatically in
    the uic generated ui_textfinder.h file by this line of code:
con's avatar
con committed

    \code
    QMetaObject::connectSlotsByName(TextFinder);
con's avatar
con committed
    \endcode

con's avatar
con 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
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    To add a resource file:
    \list 1
        \o Select \gui{File > New File or Project > Qt > Qt Resource File > Choose}.
    \image qtcreator-add-resource-wizard.png "New File or Project dialog"
con's avatar
con committed

    The \gui {Choose the Location} dialog opens.
con's avatar
con committed

        \image qtcreator-add-resource-wizard2.png "Choose the Location dialog"
        \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}.
        The \gui{Project Management} dialog opens.
con's avatar
con committed

        \image qtcreator-add-resource-wizard3.png "Project Management dialog"
con's avatar
con committed


        \o In the \gui{Add to project} field, select \bold{TextFinder.pro}
        and click \gui{Finish} to open the file in the code editor.
con's avatar
con 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"
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section1 Compiling and Running Your Program
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    Now that you have all the necessary files, click the \inlineimage qtcreator-run.png
    button to compile your program.
con's avatar
con committed
*/

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

con's avatar
con committed
/*!
    \contentspage index.html
    \previouspage creator-maemo-emulator.html
    \nextpage creator-help.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \title Using Version Control Systems
    Version control systems supported by Qt Creator are:
        \header
            \i \bold{Version Control System}
            \i \bold{Address}
            \i \bold{Notes}
        \row
            \i  \bold{Subversion}
            \i  \l{http://subversion.tigris.org/}
            \i  Server version 2006.1 and later
        \row
            \i  \bold{CVS}
            \i  \l{http://www.cvshome.org}
            \i
        \row
            \i  \bold{Mercurial}
            \i  \l{http://mercurial.selenic.com/}
            \i  Qt Creator 2.0 and later
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section1 Setting Up Version Control Systems
    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
    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}.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    \section1 Setting Up Common Options
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

       \o    \gui{User/alias configuration file} takes a file in mailmap format
             that lists user names and aliases. For example:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

             \code
             Jon Doe <Jon.Doe@company.com>
             Hans Mustermann <Hans.Mustermann@company.com> hm <info@company.com>
             \endcode
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

             \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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

       \o    \gui{User fields configuration file} is a simple text file
             consisting of lines specifying submit message fields that take
             user names, for example:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

             \code
             Reviewed-by:
             Signed-off-by:
             \endcode
    \endlist
    The fields above appear below the submit message. They provide completion
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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.
    \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
    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section1 Using Version Control Systems
    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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


    \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
    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
    change identifier shows a detailed description of the change.
    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.
    The same context menu is available when right-clicking on a version
    identifier in the file log view of a single file.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed


    \section2 Committing Changes

    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.

    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    \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.
                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
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
                modified files, you are prompted to stash those changes.
                The \gui Git options page contains an option to do
            \i  \gui{Clean Repository.../Clean Project...}
            \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
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
                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


        \row
            \i  \gui{Stashes...}
            \i  Displays a dialog showing the stashes created by
                \gui{Stash Snapshot...} with options to restore,
        \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



con's avatar
con committed
*/


Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \previouspage creator-editor-refactoring.html
    \page creator-editor-locator.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \title Searching With the Locator
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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....
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    To edit the currently open project's main.cpp file using the locator:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \list 1
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o Activate the locator by pressing \key Ctrl+K.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

           \image qtcreator-locator-open.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o Press \key Return.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

           The main.cpp file opens in the editor.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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
    of where in the name of an component it appears.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    To narrow down the search results, you can use the following wildcard
    characters:
    \list
        \o To match any number of any or no characters, enter \bold{*}.
        \o To match a single instance of any character, enter \bold{?}.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section1 Using the Locator Filters
    The locator allows you to browse not only files, but any items
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    defined by \bold{locator filters}. By default, the locator contains
    filters which locate:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o  Any open document
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o  Files belonging to your project, such as source, header resource,
            and .ui files
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o  Class and method definitions in your project or anywhere referenced
            from your project
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o  Help topics, including Qt documentation
        \o  Specific line in the document displayed in your editor
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    To use a specific locator filter, type the assigned prefix followed by
    \key Space. The prefix is usually a single character.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    For example, to locate symbols matching
    \l{http://doc.qt.nokia.com/4.7-snapshot/qdatastream.html}{QDataStream:}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \list 1
        \o Activate the locator.
        \o Enter \tt{\bold{: QDataStream}} (: (colon) followed by a
           \key Space and the symbol name (QDataStream)).
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
           The locator lists the results.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
           \image qtcreator-navigate-popup.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    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).
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section2 Using the Default Locator Filters

    The following locator filters are available by default:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Enter in locator
            \o  Example
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a line in the current file.
            \o  \tt{\bold{l \e{Line number}}}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a symbol definition.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{: \e{Symbol name}}}
            \o  \image qtcreator-locator-symbols.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a help topic.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{? \e{Help topic}}}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to an open file.
            \o  \tt{\bold{o \e{File name}}}
            \o  \image qtcreator-locator-opendocs.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a file in the file system (browse the file system).
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{f \e{File name}}}
            \o  \image qtcreator-locator-filesystem.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a file in any project currently open.
            \o  \tt{\bold{a \e{File name}}}
            \o  \image qtcreator-locator-files.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a file in the current project.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{p \e{File name}}}
            \o  \image qtcreator-locator-current-project.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a class definition.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{c \e{Class name}}}
            \o  \image qtcreator-locator-classes.png
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  Go to a method definition.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \o  \tt{\bold{m \e{Method name}}}
            \o  \image qtcreator-locator-methods.png
    \endtable

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \section2 Creating Locator Filters
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

           \image qtcreator-locator-customize.png

        \o Click \gui Add.
        \o In the \gui{Filter Configuration} dialog:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \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,
               to search all .h and .cpp files, enter \bold{*.h,*.cpp}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
            \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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed

    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.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \endlist
    \previouspage creator-developing-symbian.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \page creator-project-managing-sessions.html
    \nextpage creator-editor-using.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \title Managing Sessions
    When you exit Qt Creator, a snapshot of your current workspace is stored
    as a session.
    A session is a collection of:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
        \o Open projects with their dependencies
        \o Open editors
        \o Breakpoints and watches
        \o Bookmarks
    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.
    To create a new session or remove existing sessions, select \gui File >
    \gui Sessions > \gui{Session Manager}.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \image qtcreator-session-manager.png

    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

con's avatar
con committed
/*!
    \contentspage index.html
    \previouspage creator-build-dependencies.html
con's avatar
con committed
    \page creator-debugging.html
    \nextpage creator-debugging-example.html
con's avatar
con committed

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
    \title Debugging
    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.

    You can use the Qt Creator \gui Debug mode to inspect the state of your
    Qt projects while debugging.
    \image qtcreator-debugger-views.png "Native debugger views"
    In the \gui Debug mode you can interact with the debugger in several ways, including
    the following:

    \list
        \o Go through a program line-by-line or instruction-by-instruction.
        \o Interrupt running programs.
        \o Set breakpoints.
        \o Examine the contents of the call stack.
        \o Examine and modify registers and memory contents of
           the debugged program.
        \o Examine and modify registers and memory contents of
           local and global variables.
        \o Examine the list of loaded shared libraries.
        \o Create snapshots of the current state of the debugged program
           and re-examine them later.
    \endlist

    Qt Creator displays the raw information provided by the native debuggers
    in a clear and concise manner with the goal to simplify the debugging process
    as much as possible without losing the power of the native debuggers.

    In addition to the generic IDE functionality provided by stack view, views for
    locals and watchers, registers, and so on, Qt Creator includes
    features to make debugging Qt-based applications easy. The debugger
    plugin understands the internal layout of several Qt classes, for
    example, QString, the Qt containers, and most importantly QObject
    (and classes derived from it), as well as most containers of the C++
    Standard Library and some gcc and Symbian extensions. This
    deeper understanding is used to present objects of such classes in
    a useful way.

    For an example of how to debug applications in the \gui Debug mode, see
    \l{Debugging the Example Application}.
    For more information about the functions available in the \gui Debug mode,