qtcreator.qdoc 93.1 KB
Newer Older
1 2 3 4 5 6
// **********************************************************************
// 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.
// **********************************************************************

7

con's avatar
con committed
8 9 10
/*!
    \contentspage{index.html}{Qt Creator}
    \page index.html
11
    \nextpage creator-quick-tour.html
con's avatar
con committed
12 13 14

    \title Qt Creator Manual

con's avatar
con committed
15
    \section1 Version 1.3.80
con's avatar
con committed
16 17 18 19 20

    The goal of Qt Creator is to provide a cross-platform, complete Integrated
    Development Environment (IDE) to develop Qt projects. It is available for
    the Linux, Mac OS X and Windows platforms.

21
    \note Please report bugs and suggestions to the
con's avatar
con committed
22
    \l{http://bugreports.qt.nokia.com}{Qt Bug Tracker}.
23 24 25 26 27
    You can also join the Qt Creator mailing list. To subscribe,
    send a message with the word \e subscribe to
    \l{mailto:qt-creator-request@trolltech.com}
    {qt-creator-request@trolltech.com}. For more information on Qt mailing
    lists, visit \l{http://lists.trolltech.com}{http://lists.trolltech.com}.
con's avatar
con committed
28

29 30
    \raw HTML
    <img border="0" style="float:right;" src="images/qtcreator-screenshots.png" />
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
31
    \endraw
32

con's avatar
con committed
33
    \list
34 35 36
       \o   \l{A Quick Tour of Qt Creator}
       \o   \l{Creating a Project in Qt Creator}
       \o   \l{Writing a Simple Program with Qt Creator}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
37 38
       \o   \l{The Code Editor}
       \o   \l{Navigating Around Your Code with Locator}
39
       \o   \l{Session Management in Qt Creator}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
40 41
       \o   \l{Qt Version Management}
       \o   \l{Project Settings}
42 43
       \o   \l{CMake Support in Qt Creator}
       \o   \l{Support for Generic Projects in Qt Creator}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
44
       \o   \l{External Libraries}
45
       \o   \l{Development of Qt for Symbian Based Applications}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
46 47
       \o   \l{Qt Creator and Debugging}
       \o   \l{Qt Creator and Version Control Systems}
48 49 50 51
       \o   \l{Tips and Tricks}
       \o   \l{Keyboard Shortcuts}
       \o   \l{Glossary}
       \o   \l{Supported Platforms}
52
       \o   \l{Known Issues}
53
       \o   \l{Acknowledgements}
con's avatar
con committed
54 55 56
    \endlist
*/

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
57

con's avatar
con committed
58 59
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
60
    \previouspage index.html
con's avatar
con committed
61
    \page creator-quick-tour.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
62
    \nextpage creator-creating-project.html
con's avatar
con committed
63

64
    \title A Quick Tour of Qt Creator
con's avatar
con committed
65

66 67
    The labeled screenshot below shows some of the components of Qt Creator, in
    \gui Edit mode.
con's avatar
con committed
68 69 70

    \image qtcreator-breakdown.png

Kavindra Palaraja's avatar
Kavindra Palaraja committed
71
    \section1 The Mode Selectors
con's avatar
con committed
72

73 74
    When working in Qt Creator, you can be in one of six modes: \bold Welcome,
    \bold Edit, \bold Debug, \bold Projects, \bold Help, and \bold Output.
con's avatar
con committed
75

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
76
    Mode selectors allow you to quickly switch between tasks: editing, browsing
77
    the Qt Creator manual, setting up the build environment, etc. You can
con's avatar
con committed
78
    activate a mode by either clicking on its mode selector, or using the
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
79 80
    \l{keyboard-shortcuts}{corresponding keyboard shortcut}. Certain actions also
    trigger a mode change, e.g., \gui{Debug}/\gui{Start debugging} switches
con's avatar
con committed
81 82 83 84
    to the \gui Debug mode.

    \list

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
85 86 87
    \o \gui{Welcome mode} - Displays a welcome screen allowing you to quickly
    load sessions or recent individual projects. This is the mode displayed
    when Qt Creator is run without command line switches.
con's avatar
con committed
88

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
89 90
    \o \gui{Edit mode} - Lets you edit both project and source files. A sidebar
    on the left provides different views for navigating between files.
con's avatar
con committed
91

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
92 93
    \o \gui{Debug mode} - Provides various ways to inspect the state of the
    program while debugging. See \l{Qt Creator and Debugging} for a hands-on
94
    description of how to use this mode.
con's avatar
con committed
95

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
96
    \o \gui{Projects mode} - Lets you configure how projects can be built and
97
    executed. Under the list of projects, there are tabs to configure the
98
    build, run, and editor settings.
con's avatar
con committed
99

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
100
    \o \gui{Help mode} - Shows all documentation registered by Qt Assistant,
con's avatar
con committed
101 102
    such as the Qt library and Qt Creator documentation.

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
103
    \o \gui{Output mode} - Lets you examine various data in detail, for example
104 105
    build issues as well as compile and application output. This information
    is also available in the output panes.
con's avatar
con committed
106 107 108 109 110 111

    \endlist


    \section1 The Output Panes

112 113
    The task pane in Qt Creator can display one of four different panes:
    \gui{Build Issues}, \gui{Search Results}, \gui{Application Output}, and
114
    \gui{Compile Output}. These panes are available in all modes.
con's avatar
con committed
115

116

117
    \section2 Build Issues
con's avatar
con committed
118

119 120
    The \gui{Build Issues} pane provides a list of issues, e.g., error messages
    or warnings that need to be fixed. It filters out irrelevant output from
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
121
    the compiler and presents the issues in an organized way.
con's avatar
con committed
122

123
    \image qtcreator-build-issues.png
con's avatar
con committed
124

125

con's avatar
con committed
126 127
    \section2 Search Results

128 129 130 131
    The \gui{Search Results} pane displays the results for global searches such
    as searching within a current document, files on disk, or all projects. In
    the screenshot below, we searched for all occurrences of \c{textfinder}
    within the \c{"/TextFinder"} folder.
con's avatar
con committed
132 133 134

    \image qtcreator-search-pane.png

135

con's avatar
con committed
136 137
    \section2 Application Output

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
138 139
    The \gui{Application Output} pane displays the status of a program when
    it is executed, and the debug output, e.g., output from qDebug().
con's avatar
con committed
140 141 142

    \image qtcreator-application-output.png

143

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
144
    \section2 Compile Output
con's avatar
con committed
145

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
146 147
    The \gui{Compile Output} pane provides all output from the compiler. In
    other words, it is a more detailed version of information displayed in the
148
    \gui{Build Issues}
con's avatar
con committed
149 150 151

    \image qtcreator-compile-pane.png

152

con's avatar
con committed
153 154 155
    \section1 Qt Help Integration

    Qt Creator comes fully integrated with all of Qt's documentation and
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
156 157
    examples via the Qt Help plugin. To view the documentation, switch
    to the \gui{Help} mode. To obtain context sensitive help, move the text
con's avatar
con committed
158
    cursor to a Qt class or function and press \key{F1}. The documentation
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
159 160
    is displayed in a pane on the right, as shown in the screenshot
    below. If there is enough vertical space, it is shown in the
161
    fullscreen help mode.
con's avatar
con committed
162 163 164

    \image qtcreator-context-sensitive-help.png

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
165 166 167
    External documentation provided by the user can be used to augment or
    replace the documentation shipped with Qt Creator and Qt.

con's avatar
con committed
168 169 170 171

    \section1 Qt Designer Integration

    Qt Creator is fully integrated with Qt Designer to help you design user
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
172
    interface forms like you would with the standalone version. The Qt
con's avatar
con committed
173
    Designer integration also includes project management and code completion.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
174
    For more information on Qt Designer, see
175
    \l{http://doc.trolltech.com/designer-manual.html}{The Designer Manual}.
con's avatar
con committed
176 177 178 179 180

    \image qtcreator-formedit.png


    \section1 Keyboard Navigation
181

182 183 184
    Qt Creator caters not only to developers who are used to using the mouse,
    but also to developers who are more comfortable with the keyboard. A wide
    range of \l{keyboard-shortcuts}{keyboard} and
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
185
    \l{Navigating Around Your Code with Locator}{navigation} shortcuts
186
    are available to help speed up the process of developing your application.
con's avatar
con committed
187 188
*/

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
189 190
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
191
    \previouspage creator-writing-program.html
192
    \page creator-code-editor.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
193
    \nextpage creator-navigation.html
194 195 196

    \title The Code Editor

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
197 198 199 200 201 202 203 204
    Qt Creator's code editor is designed to aid the developer in creating, editing,
    and navigating code. It is fully equipped with syntax highlighting, code
    completion, context sensitive help, and inline error indicators
    while you are typing.

    \section1 Code Editor Configuration

    The screenshots below show the various dialogs within
205
    which you can configure your editor.
206

207 208 209
    \table
        \row
            \i  \inlineimage qtcreator-texteditor-fonts.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
210
        \row
211 212 213
            \i  \inlineimage qtcreator-texteditor-behavior.png
        \row
            \i  \inlineimage qtcreator-texteditor-display.png
214
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
215
            \i  \inlineimage qtcreator-texteditor-completion.png
216
    \endtable
217

218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
    \section1 Code Completion

    The completion popup shows possible completions to a certain statement.
    These completions include classes, namespaces, functions, variables,
    macros and keywords. Listed below are the icons used in the completion box
    and their meaning.

    \table
        \row
            \i  \inlineimage completion/class.png
            \i  A class
        \row
            \i  \inlineimage completion/enum.png
            \i  An enum
        \row
            \i  \inlineimage completion/enumerator.png
            \i  An enumerator (value of an enum)
        \row
            \i  \inlineimage completion/func.png
            \i  A function
        \row
            \i  \inlineimage completion/func_priv.png
            \i  A private function
        \row
            \i  \inlineimage completion/func_prot.png
            \i  A protected function
        \row
            \i  \inlineimage completion/var.png
            \i  A variable
        \row
            \i  \inlineimage completion/var_priv.png
            \i  A private variable
        \row
            \i  \inlineimage completion/var_prot.png
            \i  A protected variable
        \row
            \i  \inlineimage completion/signal.png
            \i  A signal
        \row
            \i  \inlineimage completion/slot.png
            \i  A slot
        \row
            \i  \inlineimage completion/slot_priv.png
            \i  A private slot
        \row
            \i  \inlineimage completion/slot_prot.png
            \i  A protected slot
        \row
            \i  \inlineimage completion/keyword.png
            \i  A keyword
        \row
            \i  \inlineimage completion/macro.png
            \i  A macro
        \row
            \i  \inlineimage completion/namespace.png
            \i  A namespace
    \endtable
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
275 276 277 278 279 280

    \section1 External Editor

    To switch to an external editor, select \gui{Open in external editor} from the
    \gui{Edit > Advanced} menu.

281 282 283
*/


con's avatar
con committed
284 285
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
286
    \previouspage creator-version-management.html
287
    \page creator-project-pane.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
288
    \nextpage creator-cmake-support.html
con's avatar
con committed
289

290
    \title Project Settings
con's avatar
con committed
291 292 293

    \table
        \row
294 295 296
            \i  \note This page describes Qt Creator's support for \c qmake.
                For information on CMake support, see
                \l{CMake Support in Qt Creator}.
con's avatar
con committed
297 298
    \endtable

299
    To modify the project settings of your project, switch to the \gui{Projects}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
300
    mode by using the mouse or pressing \key{Ctrl+4}.
con's avatar
con committed
301

302
    \image qtcreator-projectpane.png
con's avatar
con committed
303

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
304 305
    The project pane is divided into two areas. The currently active settings are
    displayed at the top. The active build and run configuration for all projects
306 307 308
    can be changed there. The bottom area allows you to quickly get an overview
    of the build, run and editor settings as well as the dependencies between your
    projects. It also allows you to edit those settings.
con's avatar
con committed
309

310
    \section1 Build Settings
con's avatar
con committed
311

312
    Build configurations allow you to quickly switch between different build
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
313 314 315
    settings. By default, Qt Creator creates a \bold{debug} and a
    \bold{release} build configuration. Both of these configurations use the
    \l{glossary-default-qt}{default Qt version}. Action items to create, clone,
316
    or delete build configurations can be found at the top. You can have as
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
317
    many build configurations as necessary. To edit settings, click on the
318 319
    \gui{Show Details} button. Here you can specify which
    \l{glossary-project-qt}{Qt version} to use to build your project, or whether
320
    to \l{glossary-shadow-build}{shadow build} the project, for instance.
con's avatar
con committed
321

322
    \image qtcreator-ppbuildsettings.png
con's avatar
con committed
323

324
    The build system of Qt Creator is built on top of \c qmake and \c make. The
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
325
    settings for \c qmake and \c make can be changed. Qt Creator runs the
326 327 328
    make command using the correct Qt version.

    In the \bold{Build Environment} section you can specify the environment used
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
329
    for building. By default, the environment in which Qt Creator was started
con's avatar
con committed
330
    is used and modified to include the Qt version. Depending on the selected
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
331
    Qt version, Qt Creator automatically sets the necessary environment
con's avatar
con committed
332 333
    variables.

334
    \section1 Run Settings
con's avatar
con committed
335

336 337 338 339 340
    \image qtcreator-pprunsettings.png
    Qt Creator automatically creates run configurations for your project.
    These run configurations derive their executable
    from the parsed .pro files. You can also create \bold{custom executable}
    run configurations where you can freely set the executable to be run.
con's avatar
con committed
341

342 343 344
    \section1 Dependencies

    If you have multiple projects loaded in your session, you can configure
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
345 346 347 348 349 350 351
    dependencies between them. This affects the build order of your
    projects. To do this:
    \list 1
        \o Select the project for which you want to configure the dependencies.
        \o Go to the \bold{Dependencies} section.
        \o Check the checkboxes to select other projects as dependencies.
    \endlist
352
    \note This is unrelated to the dependencies inside a qmake project.
353 354
*/

355

356 357
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
358
    \previouspage creator-session.html
359
    \page creator-version-management.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
360
    \nextpage creator-project-pane.html
con's avatar
con committed
361

362
    \title Qt Version Management
con's avatar
con committed
363 364 365 366 367 368

    Qt Creator allows you to use multiple versions of Qt installed on your hard
    disk and switch between them easily.

    Qt Creator automatically detects if \c qmake is in the environment variable
    \c PATH. This \l{glossary-system-qt}{version of Qt} is referred to as
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
369 370
    \bold{Qt in PATH}. If you use only one version of Qt and it is
    already in your path and correctly set up for command line usage, you do
con's avatar
con committed
371 372 373
    not need to manually configure your Qt version.

    Otherwise, you can add your Qt version in
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
374 375
    \gui{Tools > Options... > Qt Versions} on Windows and Linux or
    in \gui{Qt Creator > Preferences... > Qt Versions} on Mac OS X.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
376

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
377 378
    The detailed settings depend on your operating system and on the targeted
    tool chain.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
379

380 381 382
        \table
        \row
            \i \image qtcreator-qt4-qtversions.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
383 384
            \i \bold{Linux and Mac OS X}

385
               On Linux and Mac OS X, set the \gui{path to qmake}
386
               to the \c qmake binary of the Qt installation. If a Qt is
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
387
               found in the \c PATH environment variable, it shows up
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
388 389
               automatically as \gui{Qt in PATH}.

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
390
               On both platforms, the platform's GNU Compiler Collection (GCC)
391 392 393
               is used to compile Qt. On Mac OS, the GCC compiler is part of XCode.
               On Linux, the Intel Compiler (ICC) is supported as a drop-in replacement
               for GCC.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
394

395 396
        \row
            \i \image qtcreator-qt4-qtversions-win-mingw.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
397 398
            \i \bold{Windows and MinGW}

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
399
               If you are on the Windows platform and used MinGW
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
400 401 402
               to compile Qt, you need to tell Qt Creator
               where MinGW is installed. This is done by setting the
               \gui{MinGW directory}.
403 404
        \row
            \i \image qtcreator-qt4-qtversions-win-msvc.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
405 406
            \i \bold{Microsoft Visual C++}

407
               If your Qt version is compiled with Microsoft Visual C++'s
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
408
               compiler, Qt Creator automatically sets the correct
409
               environment variables for compilation. The \gui{MSVC}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
410
               drop-down box indicates the internal version number of the
411
               installed Microsoft Visual C++ tool chains:
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
412

413 414 415 416 417
               \list
                   \o  \bold{7.1}: Visual Studio 2003
                   \o  \bold{8.0}: Visual Studio 2005
                   \o  \bold{9.0}: Visual Studio 2008
               \endlist
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
418

419
               If you are using the \c{Windows SDK for Windows Server 2008}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
420
               instead of Visual Studio, it identifies as version 9.0.
421 422
        \row
            \i \image qtcreator-qt4-qtversions-win-symbian.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
423 424
            \i \bold{Symbian}

425
               If you are using Qt for Symbian and your S60 SDK is registered
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
426 427 428 429
               with \c devices.exe, Qt Creator detects the Qt version
               automatically.
               It is shown in the \bold{Auto-detected} section in the options
               dialog.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
430 431 432
               You can also manually add Qt for Symbian versions. In this case
               you need to tell Qt Creator the path to the S60 SDK
               it is supposed to use with these Qt installations.
433
               Add the path to your Carbide C++ install, version 2.0
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
434 435 436 437
               or later, if you want to build for the emulator
               (\c WINSCW tool chain).
               If you want to use \c GCCE to build for your device,
               you might need to add the path to the
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
438
               \c{CSL ARM Toolchain} directory (\gui{CSL/GCCE Directory}),
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
439 440
               if the compiler is not found in the \c PATH environment
               variable.
441
        \endtable
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
442

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
443
    \note By default, projects are compiled with the
con's avatar
con committed
444
    \l{glossary-default-qt}{default Qt version}. You can override this in the
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
445
    \gui{build configuration}.
con's avatar
con committed
446 447
*/

448

con's avatar
con committed
449 450
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
451
    \previouspage creator-quick-tour.html
con's avatar
con committed
452 453 454 455 456 457 458
    \page creator-creating-project.html
    \nextpage creator-writing-program.html

    \title Creating a Project in Qt Creator

    \table
        \row
459
            \i \inlineimage qtcreator-new-project.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
460
            \i \bold{Creating a new project}
con's avatar
con committed
461

462 463
        To create a new project, select \gui{New Project} from the \gui{File} menu.
        You can create one of the following three projects:
464

465 466 467 468 469
        \list
            \o Qt4 Console Application
            \o Qt4 Gui Application
            \o C++ Library
        \endlist
con's avatar
con committed
470

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
471
        In this example, we select a \e{Qt4 Gui Application} and click on \gui{OK}.
con's avatar
con committed
472 473

        \row
474
            \i \inlineimage qtcreator-intro-and-location.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
475
            \i \bold{Setting the project name and location}
con's avatar
con committed
476

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
477
        Next, we set the project's name and its path. Click on the \gui{Choose...}
con's avatar
con committed
478 479 480 481 482
        button to browse and select your path.

        Ideally, the path should not contain spaces or special characters.

        \row
483
            \i \inlineimage qtcreator-select-modules.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
484
            \i \bold{Selecting the necessary Qt modules}
con's avatar
con committed
485

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
486
        Check the check box for each Qt module you want to include into
con's avatar
con committed
487 488
        your project.

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
489 490
        Since we started a Qt4 Gui Application, the QtCore and QtGui modules are
        set by default, but you are free to add more.
con's avatar
con committed
491 492

        \row
493
            \i \inlineimage qtcreator-class-info.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
494
            \i \bold{Specifying class information}
con's avatar
con committed
495

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
496 497 498
        Specify the name of the class you want to create. The
        \e{Header file}, \e{Source file} and \e{Form file} fields update
        automatically according to the class name you choose.
con's avatar
con committed
499

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
500 501
        Remember to select the base class for your class, either a
        QWidget, QDialog or QMainWindow, from the drop-down list.
502 503

        \row
504
            \i \inlineimage qtcreator-new-project-summary.png
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
505
            \i \bold{Creating the project}
506

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
507 508
        Finally, review the files that will be created for you. To generate your project,
        click on \gui{Done}.
509

con's avatar
con committed
510
    \endtable
511

con's avatar
con committed
512 513
*/

514

con's avatar
con committed
515 516 517 518
/*!
    \contentspage index.html
    \previouspage creator-creating-project.html
    \page creator-writing-program.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
519
    \nextpage creator-code-editor.html
con's avatar
con committed
520 521 522 523 524

    \title Writing a Simple Program with Qt Creator

    \table
        \row
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
525
        \o \note This tutorial assumes that the user has experience in writing
con's avatar
con committed
526
           basic Qt applications, designing user interfaces with Qt Designer
Kavindra Devi Palaraja's avatar
Kavindra Devi Palaraja committed
527
           and using the Qt Resource System.
con's avatar
con committed
528 529 530
    \endtable


Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
531
    In this example, we describe the steps involved in using Qt Creator
con's avatar
con committed
532 533
    to create a small Qt program, Text Finder. Inspired by the QtUiTools'
    \l{http://doc.trolltech.com/uitools-textfinder.html}{Text Finder}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
534
    example, we write a similar but simplified version of it, as shown
con's avatar
con committed
535 536 537 538 539 540
    below.

    \image qtcreator-textfinder-screenshot.png

    \section1 Setting Up Your Environment

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
541 542 543
    Once you have installed Qt Creator, it detects automatically if Qt's
    location is in your \c PATH variable. If not, please follow the
    instructions in \l{Qt Version Management}.
con's avatar
con committed
544

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
545
    \section1 Setting Up the Project
con's avatar
con committed
546 547 548

    We begin with a Qt4 Gui Application project generated by Qt Creator. The
    \l{Creating a Project in Qt Creator} document describes this process in
549
    detail. Remember to select QWidget as the Text Finder's base class. If
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
550
    your project is not yet loaded, load it by selecting \gui{File} > \gui{Open}.
con's avatar
con committed
551

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
552
    In your project, you have the following files:
con's avatar
con committed
553 554 555 556 557 558 559 560

    \list
        \o \c{textfinder.h}
        \o \c{textfinder.cpp}
        \o \c{main.cpp}
        \o \c{textfinder.ui}
        \o \c{textfinder.pro}
    \endlist
561

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
562 563
    The \c{.h} and \c{.cpp} files come with the necessary boiler plate code.
    The \c{.pro} file is also complete.
con's avatar
con committed
564

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

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
567 568
    We begin by designing the user interface and then move on to filling
    in the missing code. Finally, we add the find functionality.
con's avatar
con committed
569

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
570
    \section2 The User Interface
con's avatar
con committed
571 572

    To begin designing the user interface, double-click on the
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
573
    \c{textfinder.ui} file in the \gui{Project Explorer}. This launches the
con's avatar
con committed
574 575
    integrated Qt Designer.

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
576 577 578 579 580 581 582 583
    Design the form below with:
    \list
        \o \l{http://doc.trolltech.com/qlabel.html}{QLabel}
        \o \l{http://doc.trolltech.com/qlinedit.html}{QLineEdit} (named lineEdit)
        \o \l{http://doc.trolltech.com/qpushbutton.html}{QPushButton} (named findButton)
        \o \l{http://doc.trolltech.com/qtextedit.html}{QTextEdit} (named textEdit)
    \endlist

con's avatar
con committed
584 585
    \image qtcreator-textfinder-ui.png

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
586 587 588 589 590 591
    We recommend that you use a \l{http://doc.trolltech.com/qgridlayout.html}{QGridLayout}
    to lay out the label, the line edit and the push button.
    The grid layout and the text edit can then be added to a
    \l{http://doc.trolltech.com/qvboxlayout.html}{QVBoxLayout}.
    If you are new to designing forms with \QD, see the
    \l{http://doc.trolltech.com/designer-manual.html}{Qt Designer Manual}.
con's avatar
con committed
592 593 594

    \section2 The Header File

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
595
    The \c{textfinder.h} file already has the necessary #includes, a
con's avatar
con committed
596 597 598
    constructor, a destructor, and the \c{Ui} object. We need to add a private
    slot, \c{on_findButton_clicked()}, to carry out our find operation. We
    also need a private function, \c{loadTextFile()}, to read and display the
599 600 601
    contents of our input text file in the
    \l{http://doc.trolltech.com/qtextedit.html}{QTextEdit}. This is done with
    the following code:
con's avatar
con committed
602

603
    \snippet examples/textfinder/textfinder.h 0
604

605
    \note The \c{Ui::TextFinder} object is already provided.
con's avatar
con committed
606 607 608 609

    \section2 The Source File

    Now that our header file is complete we move on to our source file,
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
610 611
    \c{textfinder.cpp}. We begin by filling in the functionality to load a
    text file. This is described in the code snippet below:
con's avatar
con committed
612

613
    \snippet examples/textfinder/textfinder.cpp 0
con's avatar
con committed
614

615 616 617 618
    Basically, we load a text file using
    \l{http://doc.trolltech.com/qfile.html}{QFile}, read it with
    \l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, and
    then display it on \c{textEdit} with
hjk's avatar
hjk committed
619 620
    \l{http://doc.trolltech.com/qtextedit.html#plainText-prop}{setPlainText()}
    which requires adding the following additional #includes to textfinder.cpp:
621 622

    \snippet examples/textfinder/textfinder.cpp 1
con's avatar
con committed
623 624

    For the \c{on_findButton_clicked()} slot, we extract the search string and
625
    use the \l{http://doc.trolltech.com/qtextedit.html#find}{find()} function
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
626 627
    to look for the search string within the text file. This is described in
    the code snippet below:
con's avatar
con committed
628

629
    \snippet examples/textfinder/textfinder.cpp 2
con's avatar
con committed
630

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
631
    Once we have both of these functions complete, we call \c{loadTextFile()} in
con's avatar
con committed
632 633
    our constructor.

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

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

    \code
640
    QMetaObject::connectSlotsByName(TextFinder);
con's avatar
con committed
641 642 643 644
    \endcode

    \section2 The Resource File

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
645 646 647 648 649 650 651 652 653
    We require a resource file (\c{.qrc}) within which we embed the input
    text file. This can be any \c{.txt} file with a paragraph of text.

    To add a resource file:
    \list 1
        \o Right-click on \gui{Resource Files} in the \gui{Project Explorer}.
        \o Select \gui{Add New File...}.
    \endlist
    The wizard dialog below is displayed.
con's avatar
con committed
654 655 656

    \image qtcreator-add-resource-wizard.png

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
657 658 659 660 661
    \list 3
        \o Enter "textfinder" in the \gui{Name} field. Use the given \gui{Path}.
        \o Click on \gui{Continue}.
    \endlist
    This page is displayed:
662 663 664

    \image qtcreator-add-resource-wizard2.png

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
665 666 667 668 669 670
    \list 5
        \o Choose to which project you want to add the new file. Select "TextFinder"
        as the \gui{Project}.
        \o Make sure that \gui{Add to Project} is checked.
        \o Click on \gui{Done}.
    \endlist
con's avatar
con committed
671

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
672
    Your resource file is now displayed in the resource editor.
con's avatar
con committed
673

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
674 675 676 677 678 679
    \list 8
        \o Select \gui{Add} > \gui{Add Prefix} from the drop-down list. The prefix we
        require is a slash (\c{/}).
        \o Select \gui{Add} > \gui{Add File} from the drop-down list.
        \o Locate the text file you are going to use. We use \c{input.txt}.
    \endlist
con's avatar
con committed
680

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
681
    Once the resource file has been successfully added, the following is displayed:
con's avatar
con committed
682

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
683
    \image qtcreator-add-resource.png
con's avatar
con committed
684

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
685
    \section1 Compiling and Running your Program
con's avatar
con committed
686

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

con's avatar
con committed
690 691
*/

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
692

con's avatar
con committed
693 694
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
695
    \previouspage creator-debugging.html
696
    \page creator-version-control.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
697
    \nextpage creator-tips.html
698 699 700 701 702 703 704 705

    \title Qt Creator and Version Control Systems

    \table
        \caption    Version control systems supported by Qt Creator
        \row
            \i  \bold{git}
            \i  \l{http://git-scm.com/}
706
            \i
707 708 709
        \row
            \i  \bold{Subversion}
            \i  \l{http://subversion.tigris.org/}
710
            \i
711 712 713
        \row
            \i  \bold{Perforce}
            \i  \l{http://www.perforce.com}
714
            \i  Server version 2006.1 and later
715 716 717 718
        \row
            \i  \bold{CVS}
            \i  \l{http://www.cvshome.org}
            \i
719 720 721
    \endtable


Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
722
    \section1 Setting Up Version Control Systems
723 724 725

    Qt Creator uses the version control system's command line clients to
    access your repositories. To set it up, you must ensure that these command
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
    line clients can be located via the \c{PATH} environment variable.
    To specify the path to the command line client's executable, go to the settings
    pages in \gui{Tools} > \gui{Options...}.


    \section1 Setting Up Common Options

    The \gui{Version Control > Common} settings page features common settings for
    version control systems, such as commit message line wrapping and checking
    options.

    \gui{Submit message checking 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.

    \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

    Notice that the second line 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.

    \gui{User field 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
764

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
765 766 767 768
    These fields 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.
769 770


Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
771
    \section1 Using Version Control Systems
772

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
773 774
    The version control sub-menus are in \gui{Tools} menu. The version control system
    managing the current project is displayed here.
775 776

    Each version control system adds a pane to the \gui{Application Output}
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
777
    panes within which itlogs the commands it executes, prepended by a
778 779 780 781 782 783 784
    timestamp and the relevant output.

    \image qtcreator-vcs-pane.png


    \section2 Addings Files

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
785 786 787
    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
788
    under version control and the system supports the concept of adding files,
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
789 790
    e.g., \bold{Perforce} and \bold{Subversion}. Alternatively, you can
    add files later by using the version control tool menus.
791 792 793 794 795 796 797 798

    With \bold{git}, there is no concept of adding files. Instead, all modified
    files must be \e{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
799 800 801 802
    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
803 804 805 806 807
    displaying the file, scrolled to the line in question.

    \image qtcreator-vcs-diff.png


808 809 810
    \section2 Annotating Files

    Annotation views are obtained by selecting \gui{Annotate} or \gui{Blame}.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
811
    This displays the lines of the file prepended by the change identifier
812 813 814 815 816 817 818
    they originate from. Clicking on the change identifier shows a detailed
    description of the file.


    \section2 Committing Changes

    Once you have finished making changes, you can submit them to the version
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
819 820
    control system by choosing \gui{Commit} or \gui{Submit}. Qt Creator
    displays a commit page containing a text editor, where you can enter your
821
    commit message, and a checkable list of modified files to be included.
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
822 823
    When you are done, click on \gui{Commit} to start committing. In addition,
    there is a \gui{Diff Selected Files} button that brings up a diff view of the
824 825 826 827 828 829 830
    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. Alternatively, you
    can view it from the editor combo box showing the \gui{Opened files}.

    \image qtcreator-vcs-commit.png


Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
831 832 833 834 835 836 837 838 839 840 841 842 843
    \section2 Viewing Versioning History and Change Details

    The versioning history of a file is displayed by selecting
    \gui{Log} (for \bold{git}) or \gui{Filelog} (for \bold{Perforce} and
    \bold{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.

    \image qtcreator-vcs-log.png
    \image qtcreator-vcs-describe.png


    \section2 Using git-specific Menu Entries
844 845 846 847 848 849 850 851

    The git sub-menu contains additional entries:

    \table
        \row
            \i  \gui{Stash}
            \i  Stash local changes prior to executing a \bold{pull}.
        \row
852 853
            \i  \gui{Pull}
            \i  Pull changes from the remote repository. If there are locally
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
854
                modified files, you are prompted to stash those changes.
855 856 857 858
        \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
859 860 861
                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.
862 863

                \image qtcreator-vcs-gitbranch.png
864
    \endtable
865

866

con's avatar
con committed
867 868 869
*/


870 871
/*!
    \contentspage index.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
872
    \previouspage creator-code-editor.html
873
    \page creator-navigation.html
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
874
    \nextpage creator-session.html
875

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
876
    \title Navigating Around Your Code with Locator
877 878

    With Qt Creator, navigating to different locations in your project or on
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
879 880
    your disk, e.g., files, classes, methods, etc., is simple using
    \gui Locator -- a smart line edit at the bottom left in Qt Creator
881 882 883 884
    window.

    \image qtcreator-locator.png

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
885 886 887 888 889 890 891 892
    For example, to open your project's \c{main.cpp} file:
    \list 1
        \o Click on \gui Locator or press \key{Ctrl+K} (Mac OS X: \key{Cmd+K}).
        \o Type in the file name.
        \o Press \key Return.
    \endlist
    The file opens in the editor.

893
    You can also type part of a file name and use the wildcard characters
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
894
    \c{*} and \c{?} to match \e{any} number of \e{any} characters. A list
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
895
    of files matching your criteria is displayed.
896

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
897 898
    \gui Locator allows you to navigate files both on disk and in other
    "locations", which are organized with \bold{Filters}. There are
899 900 901
    filters for:

    \list
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
902 903 904 905 906 907 908 909 910
        \o  Files anywhere on your hard disk (browsing through the file system)
        \o  Files from a subdirectory structure defined by you
        \o  Files mentioned in your \c{.pro} files, such as source, header
            resource, and \c{.ui} files
        \o  Any open document
        \o  Class and method definitions in your project or anywhere referenced
            from your project
        \o  Help topics, including Qt's documentation
        \o  Specific line in the document displayed on your editor
911 912 913 914 915 916
    \endlist


    Some of these filters require you to activate them by typing an assigned
    \e prefix. This prefix is usually a single character followed by
    \key{Space}. For example, to jump to the definition of the class
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
917 918 919
    \l{http://doc.trolltech.com/qdatastream.html}{QDataStream}, activate
    \gui Locator. Then type a colon (\key{:}) followed by a \key{Space} and
    the class name.
920 921 922 923 924 925 926 927 928 929


    Below is a full list of \l{http://doc.trolltech.com/qdatastream.html}
    {QDataStream} related output:

    \image qtcreator-navigate-popup.png


    Filters can be added to provide quick navigation around files in a
    subdirectory structure defined by you. This way, you can acccess files you
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952
    need that are not directly mentioned in your project.
    \list 1
        \o Click the button \image qtcreator-locator-magnify.png
        \o Select \gui{Configure...} from the menu displayed:
        \image qtcreator-locator-customize.png
        \o To create a new filter, select \gui Add from the \gui Configure...
        dialog (\gui Options on Mac Os X).
        \o In the \gui{Filter Configuration} dialog below:
        \list
            \o Give your filter a name.
            \o Select your preferred directories.
            \o Set file patterns with a comma separated list.
            \o Specify a prefix string.
        \endlist
        \image qtcreator-navigate-customfilter.png
        \o Close the dialog.
    \endlist
    \gui Locator searches the directories you selected for files matching
    your file patterns. Information is cached. To update the cached information:
    \list 1
        \o Click the button \image qtcreator-locator-magnify.png again.
        \o Select \gui Refresh.
    \endlist
953

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
954
    The following table lists available filters:
955