Newer
Older
Note that the \gui{Header file}, \gui{Source file} and
\gui{Form file} fields are automatically updated as you name your
class.
\image qtcreator-class-info.png
\o Review the project settings.

Leena Miettinen
committed
To create the project, click \gui Finish.
\image qtcreator-new-project-summary.png
\endlist
\previouspage creator-project-creating.html
\page creator-project-qmake.html
\nextpage creator-project-cmake.html
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
\section1 Selecting the Qt Version
Qt Creator allows you to have multiple versions of Qt installed on
your computer and use different versions for your projects.
If Qt Creator finds \bold qmake in the PATH environment variable, it uses
that version. This \l{glossary-system-qt}{version of Qt} is referred to as
\bold{Qt in PATH}. If you intend to use only one version of Qt and it is
already in the PATH and correctly set up for command line use, you do not
need to manually configure your Qt version.
\note By default, Qt Creator compiles projects with the
\l{glossary-default-qt}{default Qt version}. For information on how to
override this setting, see \l{Build Settings}.
\section2 Windows
To add a Qt version for \bold MinGW:
\list 1
\o Select \gui Tools > \gui Options... > \gui Qt4 >
\gui{Qt Versions}.
\o Click \inlineimage qtcreator-windows-add.png
and enter the name of the version in \gui{Version Name} field.
\o Enter the qmake binary path in the \gui{qmake Location}.
\o Enter the MinGW installation path in the \gui{MinGW Directory}.
\image qtcreator-qt4-qtversions-win-mingw.png
\endlist
To add a Qt version for a \bold{Microsoft Visual C++} compiler:
\list 1
\o Select \gui Tools > \gui Options... > \gui Qt4 >
\gui{Qt Versions}.
\o Qt Creator automatically sets the correct environment variables for
compilation. Select the internal version number of the installed
Microsoft Visual C++ tool chains using the \gui MSVC drop-down
box:
\list
\o \bold 7.1 for Visual Studio 2003
\o \bold 8.0 for Visual Studio 2005
\o \bold 9.0 for Visual Studio 2008
\endlist
\note If you are using the
\bold{Windows SDK for Windows Server 2008}, Qt Creator identifies
it as version 9.0.
\image qtcreator-qt4-qtversions-win-msvc.png
\endlist
If you are using \bold{Qt for Symbian} and your S60 SDK is registered
with devices.exe, Qt Creator automatically detects the Qt version. To add a
Qt for Symbian version:
\list 1
\o Select \gui Tools > \gui Options... > \gui Qt4 >
\gui{Qt Versions}.
\o Select the \gui{S60 SDK} you want the Qt Creator to use.
\image qtcreator-qt4-qtversions-win-symbian.png
\o To build an application for your device using GCCE, enter the path
to the \bold{CSL ARM Toolchain} directory in
\gui{CSL\\GCCE Directory}.
You do not need to specify this path if the compiler is included in
the PATH environment variable.
\o To build an application for the emulator (WINSCW toolchain), enter
the path to your Carbide C++ installation directory in
\gui{Carbide Directory}.
You need to have Carbide C++ version 2.0 or later installed.
\endlist
\section2 Linux
To compile a project in Qt Creator, Linux uses GNU Compiler Collection
(GCC). Intel Compiler Collection (ICC) is supported as a drop-in
replacement for GCC.

Kavindra Devi Palaraja
committed
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
To add a Qt version:
\list 1
\o Select \gui Tools > \gui Options... > \gui Qt4 >
\gui{Qt Versions}.
\o Click \inlineimage qtcreator-linux-add.png
and enter the name of the version in \gui{Version Name}.
\o Enter the path to the qmake binary in \gui{Path to qmake}.
\endlist
\section2 Mac OS X
To compile a project in Qt Creator, Mac OS X uses GNU Compiler Collection
(GCC), which is part of Xcode.
To add a Qt version:
\list 1
\o Select \gui{Qt Creator} > \gui Preferences... > \gui{Qt Versions}.
\o Click \inlineimage qtcreator-macosx-add.png
and enter the name of the version in \gui{Version Name}.
\o Enter the path to the qmake binary in \gui{Path to qmake}.
\image qtcreator-qt4-qtversions.png
\endlist
\section1 Setting Up a Project
To view and modify the settings for currently open projects, switch to the
\gui Projects mode by pressing \key Ctrl+4.
\image qtcreator-projectpane.png
The project pane consists of three tabs
\list
\o Targets
\o Editor Settings
\o Dependencies
\endlist
Use the \gui Build and \gui Run buttons on *Desktop* to switch between
the build and run settings for the active project.
If you have multiple projects open in Qt Creator, use
\gui{Select a Project} option at the top to navigate between different
project edits.
\section1 Build Settings
Different build configurations allow you to quickly switch between
different build settings. By default, Qt Creator creates \bold debug
and \bold release build configurations. Both of these configurations use
the \l{glossary-default-qt}{default Qt version}.
\image qtcreator-ppbuildsettings.png
\section2 Adding and Removing Build Configurations
To add a new build configuration, click \gui Add and select the type of
configuration you would like add. You can add as many build configurations
as you need.
To delete the build configuration currently selected, click \gui Remove.
\section2 Editing Build Configurations
To edit a build configuration:
\list 1
\o Select the build configuration you want to edit in
\gui{Edit Build Configuration}.
\o In section \gui General, you can specify:
\o The \l{glossary-project-qt}{Qt version} you want to use to
build your project. For more information, see
\l{Selecting the Qt version}.
\o The toolchain required to build the project.
\o If you want to \l{glossary-shadow-build}{shadow build} your
project, check the \gui{Shadow Build} checkbox and select the
build directory.
\endlist
The build system of Qt Creator is built on qmake and make. In
\gui{Build Steps} you can change the settings for qmake and make. Qt
Creator runs the make command using the Qt version defined for the current
build configuration.
The cleaning process is used to remove intermediate files. This process
might help you to fix obscure issues during the process of building a
project.
You can define the cleaning steps for your builds in the \gui{Clean Steps}:
\list
\o To add a clean step using make or a custom process, click
\gui{Add clean step} and select the type of step you want to add.
By default, custom steps are disabled. Activate customs steps by
checking the \gui{Enable Custom Process Step} check-box.
\o To remove a clean step, click \gui{Remove clean step} and select the
step you want to remove.
\o To change the order of steps, click
\inlineimage qtcreator-movestep.png
.
\endlist
You can specify the environment you want to use for building in the
\bold{Build Environment} section. By default, the environment in which Qt
Creator was started is used and modified to include the Qt version.
Depending on the selected Qt version, Qt Creator automatically sets the
necessary environment variables. You can edit existing environment
variables or add, reset and unset new variables based on your project
requirements.
Qt Creator automatically creates run configurations for your project.
These run configurations derive their executable from the parsed .pro
files. You can also create custom executable run configurations where you
can set the executable to be run.

Kavindra Devi Palaraja
committed
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
\section1 File Encoding
To define the default file encoding, select the desired encoding in the
\gui{Editor Settings}. By default, the Qt Creator uses the file encoding
used by your system.
\section1 Dependencies
If you have multiple projects loaded in your session, you can define the
dependencies between them. This affects the build order of your
projects.
\note These dependencies are unrelated to the dependencies inside a qmake
project.
To define the dependencies:
\list 1
\o Select the project for which you want to configure dependencies.
\o In the \gui Dependencies section check the checkboxes to select
other projects as dependencies.
\endlist
\section1 Adding External Libraries to a qmake Project
Through external libraries Qt Creator can support code completion and
syntax highlighting as if they were part of the current project or the Qt
library.
To add an external library:
\list
\o Open your project file (.pro) using the \gui Projects pane.
\o Follow the instructions at \l http://doc.trolltech.com/latest/qmake-project-files.html#declaring-other-libraries
{Declaring other Libraries}.
\endlist

Kavindra Devi Palaraja
committed
Syntax completion and highlighting work once your project successfully
builds and links against the external library.

Leena Miettinen
committed
\page creator-getting-started.html
\nextpage creator-writing-program.html
\title Getting Started
This section contains examples that illustrate how to use Qt Creator and the
integrated design tools, \QD and \QMLD, to create simple applications:
\list
\o \l{Writing a Simple Program}
\o \l{Creating an Animated Application}
\endlist
*/
/*!
\contentspage index.html
\previouspage creator-writing-program.html
\page creator-qml-application.html

Leena Miettinen
committed
\title Creating an Animated Application
\note This tutorial assumes that you are familiar with the QML declarative
language.
This tutorial describes how to use Qt Creator to create a small animated
Qt application, Hello World.
\image qmldesigner-helloworld.png "Hello World"
\section1 Creating the Hello World Project
\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 Quick Project > QML Application > OK}.

Leena Miettinen
committed
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
\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 {Hello World}.
\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
\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 some example
code that specifies the screen size (200x200) and a label that contains
the text \bold {Hello World}.
\section1 Designing the User Interface
\list
\o In the \gui{Editor} mode, double-click the HelloWorld.qml file in
the \gui{Projects} pane to open it in the code editor.
\o To set the screen size to that of some Symbian devices in portrait
mode, for example, change the \c height to \bold 240 and \c width to \bold 320.
\o Click \gui{Design} to design the UI in the visual \QMLD editor.
\o Drag and drop a \gui {Rectangle} from the \gui {Library} pane to the
scene.
\image qmldesigner-helloworld-widget-add.png "Add widget to Hello World"
\o Edit the \gui {Properties} of the item to turn it into a red ball:
\list
\o In the \gui {Advanced} tab, click the color picker to select a red
color.
\o In the \gui {Radius} field, use the slider to set the radius value
to \bold 50.
\image qmldesigner-helloworld-widget-edit.png "Edit the widget"
\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 {Anchor} tab, click the
\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
\section1 Buiding and Running the Application
\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
*/
/*!
\contentspage index.html
\previouspage creator-getting-started.html
\page creator-writing-program.html
\nextpage creator-qml-application.html
\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.trolltech.com/uitools-textfinder.html}{Text Finder}
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 > OK}.

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:

Leena Miettinen
committed
\o \gui{Label} (\l{http://doc.trolltech.com/qlabel.html}{QLabel})
\o \gui{Line Edit} (\l{http://doc.trolltech.com/qlineedit.html}{QLineEdit})
\o \gui{Push Button} (\l{http://doc.trolltech.com/qpushbutton.html}{QPushButton})

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 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.trolltech.com/qhboxlayout.html}{QHBoxLayout}).
\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.trolltech.com/qtextedit.html}{QTextEdit})
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.trolltech.com/qvboxlayout.html}{QVBoxLayout}).
\image qtcreator-textfinder-ui.png "Text Finder UI"

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

Leena Miettinen
committed
Applying the horizontal and vertical layouts ensures that the application UI scales to different
screen sizes.

Leena Miettinen
committed
For more information about designing forms with \QD, see the
\l{http://doc.trolltech.com/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
slot, \c{on_findButton_clicked()}, to carry out the find operation. You
also need a private function, \c{loadTextFile()}, to read and display the

Leena Miettinen
committed
contents of the input text file in the
\l{http://doc.trolltech.com/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 slot in a \c{private slots} section and a private function
in the \c{private} section, after the \c{Ui::TextFinder} function, as
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.trolltech.com/qfile.html}{QFile}, read it with
\l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, and
then display it on \c{textEdit} with
\l{http://doc.trolltech.com/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.trolltech.com/qfile.html}{QFile} and
\l{http://doc.trolltech.com/qtextstream.html}{QTextStream}, add the
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.trolltech.com/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.

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

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

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

Leena Miettinen
committed
\nextpage adding-plugins.html

Kavindra Palaraja
committed

Kavindra Palaraja
committed
\table
\caption Version control systems supported by Qt Creator
\row
\i \bold{git}
\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

Kavindra Palaraja
committed
\endtable

Kavindra Palaraja
committed
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
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
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 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

Kavindra Palaraja
committed
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.

Kavindra Palaraja
committed
The version control sub-menus are in \gui Tools > \gui Options...
> \gui{Version Control}. The version control system
Each version control system adds a pane to the \gui{Application Output}
panes within which it logs the commands it executes, prepended by a
timestamp and the relevant output.
\image qtcreator-vcs-pane.png
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,
e.g., \bold{Perforce} and \bold{Subversion}. Alternatively, you can
add files later by using the version control tool menus.
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
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 Annotating Files
Annotation views are obtained by selecting \gui{Annotate} or \gui{Blame}.
This 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 file.
To show the annotation of a previous version in the \gui Annotate or
\gui Blame view, right-click on the version in the code. This option
allows you to navigate through the history of the file and obtain the
previous version of the code. This option also works for \gui git/hg
using SHA.
The file log view for a single file has \gui Annotate in
the context menu of the version mentioned in the log, the user can
right-click a line to open a context menu which contains
\gui{Annotate Previous}.
To set up a VCS repository for new projects, select \gui File >
\gui{New File or Project...}. It enables you to initialize a
repository for VCS that supports \gui git/hg
\section2 Committing Changes
Once you have finished making changes, you can 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 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
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
\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
The git sub-menu contains additional entries:
\table
\row
\i \gui{Stash}
\i Stash local changes prior to executing a \bold{pull}.
\row
\i \gui{Pull}
\i Pull changes from the remote repository. If there are locally
modified files, you are prompted to stash those changes.
\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
/*!
\contentspage index.html
\previouspage creator-editor-refactoring.html
\page creator-editor-locator.html
\nextpage creator-project-managing.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:
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 item it appears.
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 \tt \bold{*}.
\o To match a single instance of any character, enter \tt \bold{?}.
\endlist
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
\o Files anywhere on your file systems
\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.
For example, to locate symbols matching
\l http://doc.trolltech.com/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: