Newer
Older
In Qt Creator you can move directly to the definition or the declaration of
a symbol by holding the \key Ctrl and clicking the symbol.

Rohan Shetty
committed
To enable this moving function, in \gui Tools > \gui{Options...} >
\gui{Text Editor} > \gui Behavior select \gui{Enable mouse navigation}.
\section1 Using Update Code Model
To refresh the internal information in Qt Creator pertaining to your code,

Leena Miettinen
committed
select \gui{Tools} > \gui{C++} > \gui{Update Code Model}.
\note In Qt Creator indexing updates the code automatically. Use

Leena Miettinen
committed
\gui{Update Code Model} only as an emergency command.

Leena Miettinen
committed
*/

Leena Miettinen
committed
/*!
\contentspage index.html
\previouspage creator-editor-locator.html
\page creator-editor-codepasting.html
\nextpage creator-editor-options.html
\title Pasting and Fetching Code Snippets

Leena Miettinen
committed
In Qt Creator, you can paste snippets of code to a server or fetch
snippets of code from the server. To paste and fetch snippets of code,
Qt Creator uses the following:
\list
\o \gui{CodePaster}
\o \gui{Pastebin.Com}
\o \gui{Pastebin.Ca}
\endlist

Leena Miettinen
committed
To configure the server, select \gui{Tools} > \gui{Options...} >
\gui{Code Pasting}.
To paste a snippet of code onto the server, select \gui{Tools} >
\gui{Code Pasting} > \gui{Paste Snippet...} or press \key{Alt+C,Alt+P}.
To fetch a snippet of code from the server, select \gui{Tools} >
\gui{Code Pasting} > \gui{Fetch Snippet...} or press \key{Alt+C,Alt+F}.

Leena Miettinen
committed
\note To use \gui{Pastebin.Com}, configure the domain
prefix in \gui{Tools} > \gui{Options...} > \gui{Code Pasting} >
\gui{Pastebin.com}.

Leena Miettinen
committed
For example, you might ask colleagues to review a change that you plan to
submit to a version control system. If you use the Git version control system,

Leena Miettinen
committed
you can create a \e{diff} view by selecting \gui{Tools} > \gui{Git} >
\gui{Diff Repository}. You can then upload its contents to the server by choosing
\gui{Tools} > \gui{Code Pasting} > \gui{Paste Snippet...}. The reviewers can retrieve
the code snippet by selecting \gui{Tools} > \gui{Code Pasting} > \gui{Fetch Snippet...}.
If they have the project currently opened in Qt Creator, they can apply and test
the change by choosing \gui{Tools} > \gui{Git} > \gui{Apply Patch}.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-editor-options.html
\page creator-editor-fakevim.html
\nextpage creator-editor-external.html
\title Using FakeVim Mode
In the \gui{FakeVim} mode, you can run the main editor in a manner similar
to the Vim editor. To run the editor in the \gui{FakeVim} mode, select

Leena Miettinen
committed
\gui{Edit} > \gui{Advanced} > \gui{Use Vim-style Editing} or press
\key{Alt+V,Alt+V}.
In the \gui{FakeVim} mode, most keystrokes in the main editor will be
intercepted and interpreted in a way that resembles Vim. Documentation for
Vim is not included in Qt Creator. For more information on using Vim,
see \l{http://www.vim.org/docs.php}{Documentation} on the Vim web site.
To map commands entered on the \gui{FakeVim} command line to actions of the
Qt Creator core, select \gui{Tools} > \gui{Options...} > \gui{FakeVim} >
\gui{Ex Command Mapping}.

Leena Miettinen
committed
To make changes to the Vim-style settings, select \gui{Tools} >
\gui{Options...} > \gui FakeVim > \gui{General}.
To use a Vim-style color scheme, select \gui {Tools > Options... >
Text Editor > Fonts & Color}. In the \gui {Color Scheme} list, select
\gui {Vim (dark)}.
To quit the FakeVim mode, click \gui {Quit FakeVim} or press
\key{Alt+V,Alt+V}.

Leena Miettinen
committed
*/
/*!
\contentspage index.html
\previouspage creator-editor-fakevim.html
\page creator-editor-external.html
\nextpage creator-design-mode.html

Leena Miettinen
committed
\title Using an External Editor
To open the file you are currently viewing in an external editor, select
\gui Edit > \gui Advanced > \gui{Open in External Editor}.
To use the external editor of your choice:
\list 1

Rohan Shetty
committed
\o Add the editor path to the \c{PATH} environment variable of your
operating system.
\o In Qt Creator select \gui Tools > \gui Options... >
\gui Environment > \gui General.
\o In \gui{External editor} enter the name of the application followed
by \key Space and \tt{\bold %f}. For example, to open the file in
Smultron, enter \tt{\bold{smultron %f}}.
To further define how to open the file in the external editor, you
can use the following variables separated by a space:
\list
\o Current line number \tt{\bold %l}
\o Current column number \tt{\bold %c}
\o Editor's x position on the screen \tt{\bold %x}
\o Editor's y position on the screen \tt{\bold %y}
\o Editor's width in pixels \tt{\bold %w}
\o Editor's height in pixels \tt{\bold %h}
\o Editor's width in characters \tt{\bold %W}
\o Editor's height in characters \tt{\bold %H}
\o To pass % symbol to the editor \tt{\bold %%}
\endlist
\note Not all variables work with all editors.
\endlist

Kavindra Palaraja
committed
*/

Leena Miettinen
committed
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
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
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
/*!
\contentspage index.html
\previouspage creator-editor-codepasting.html
\page creator-editor-options.html
\nextpage creator-editor-fakevim.html
\title Configuring the Editor
Qt Creator allows you to configure the text editor to suit your specific
needs. To configure the editor, select \gui Tools > \gui{Options...} >
\gui{Text Editor}.
You can perform the following configuration actions:
\list
\o Set the font preferences and apply syntax highlighting in
\gui{Font & Colors}.
\o Set tabs, indentation, the handling of whitespace, and mouse operations in
\gui Behavior.
\o Set various display properties, for example,
\l{Highlighting and folding blocks}{highlighting and folding blocks},
text wrapping or \l{Moving to symbol definition or declaration}
{moving to symbol definition or declaration}
in \gui Display.
\o Configure \l{Completing Code}{code completion} in \gui Completion.
\endlist
\section2 Configuring Fonts
You can select the font family and size. You can specify a zoom setting in
percentage for viewing the text. You can also zoom in or out by pressing
\key {Ctrl++} or \key {Ctrl +-}, or by pressing \key Ctrl and rolling
the mouse button up or down. To disable the mouse wheel function, select
\gui {Tools > Options... > Text Editor > Behavior} and deselect the
\gui {Enable scroll wheel zooming} check box.
Antialiasing is used by default to make text look smoother and more
readable on the screen. Deselect the \gui Antialias check box to
turn off antialiasing.
\section2 Defining Color Schemes
You can select one of the predefined color schemes for syntax highlighting
or create customized color schemes. To create a color scheme:
\list 1
\o Select \gui {Tools > Options... > Text Editor > Fonts & Color > Copy}.
\o Enter a name for the color scheme and click \gui OK.
\o In the \gui Foreground field, specify the color of the selected
code element.
\o In the \gui Background field, select the background
color for the code element.
The backgound of the \gui Text element determines the background of the
code editor.
\endlist
When you copy code from Qt Creator, it is copied in both plain text and HTML
format. The latter makes sure that syntax highlighting is preserved when
pasting to a rich-text editor.
\section2 Indenting Code
When you type code, it is indented automatically according to the selected
options. Select a block to indent it when you press \key Tab.
Press \key {Shift+Tab} to decrease the indentation.
When you press \gui Backspace the indentation is decreased by one level,
instead of one space, by default.
By default, the tab-length in code editor is 8 spaces, but you can change
it. The code editor can also determine whether tabs or spaces are used
on the previous or next line and copy the style.
You can determine whether the block indent style includes braces,
or you can use the GNU indent style. The GNU style places braces on a separate
line, indented by 2 spaces, except when they open a function definition, where
they are not indented.
The following code snippet illustrates excluding braces from the indented block:
\code
void foobar(bool zoo)
{
if (zoo)
{
foo();
}
}
\endcode
The following code snippet illustrates including braces in the indented block:
\code
void foobar(bool zoo)
{
if (zoo)
{
foo();
}
}
\endcode
The following code snippet illustrates the GNU style:
\code
void foobar(bool zoo)
{
if (zoo)
{
foo();
}
}
\endcode
*/
\previouspage creator-editor-using.html
\page creator-editor-finding.html
\nextpage creator-editor-refactoring.html
To search through the currently open file:
\list 1
\o Press \key Ctrl+F or select \gui Edit > \gui Find/Replace >

Rohan Shetty
committed
\gui{Find/Replace}.
\o Enter the text you are looking for.
If the text is found, all occurrences are highlighted as you type.
\o To go to the next occurrence, click \inlineimage qtcreator-next.png
, or press \key F3. To go to the previous occurrence click
\inlineimage qtcreator-previous.png
, or press \key Shift+F3.
\endlist

Leena Miettinen
committed
You can restrict the search in the \gui Find field by selecting one
or several search criteria:
\list
\o To make your search case sensitive, select
\inlineimage qtcreator-editor-casesensitive.png
.
\o To search only whole words, select
\inlineimage qtcreator-editor-wholewords.png
.
\o To search using regular expressions, select
\inlineimage qtcreator-editor-regularexpressions.png
.

Leena Miettinen
committed
Regular expressions used in Qt Creator are modeled on Perl regular
expressions. For more information on using regular expressions, see

Leena Miettinen
committed
\l {http://doc.qt.nokia.com/4.6/qregexp.html#details}
{Detailed Description} in the QRegExp Class Reference.

Leena Miettinen
committed
\note If you have selected text before selecting \gui Find/Replace, the
search is conducted within the selection.
To replace occurrences of the existing text, enter the new text in the

Leena Miettinen
committed
\gui{Replace with} field.
\list
\o To replace the selected occurrence and move to the next one,
click \inlineimage qtcreator-next.png
or press \key Ctrl+=.
\o To replace the selected occurrence and move to the previous one,
click \inlineimage qtcreator-previous.png
.
\o To replace all occurrences in the file, click \gui{Replace All}.
\endlist
To search through projects, files on a file system or the currently open
file:
\list 1
\o Press \key Ctrl+Shift+F or select \gui Edit >
\gui Find/Replace > \gui{Advanced Find} >
\gui{Open Advanced Find...}.
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
\o Select the scope of your search:
\list
\o \gui{All Projects} searches files matching the defined file
pattern in all currently open projects.
For example, to search for \tt previewer only in \tt .cpp
and \tt .h files, enter in \gui{File pattern}
\tt *.cpp,*.h.
\image qtcreator-search-allprojects.png
\o \gui{Current Project} searches files matching the defined file
pattern only in the project you are currently editing.
\o \gui{Files on File System} recursively searches files matching
the defined file pattern in the selected directory.
\o \gui{Current File} searches only the current file.
\endlist
\o Enter the text you are looking for and click \gui Search.
\image qtcreator-searchresults.png
A list of files containing the searched text is displayed in the
\gui{Search Results} pane.
\list
\o To see all occurrences in a file, double-click the file name in
the list.
\o To go to an occurrence, double-click it.
\endlist
\endlist
*/
/*!
\contentspage index.html
\previouspage creator-editor-finding.html
\page creator-editor-refactoring.html
\nextpage creator-editor-locator.html
Code refactoring is the process of changing the code without modifying the
existing functionality of your application. By refactoring your code you
can:
\list
\o Improve internal quality of your application
\o Improve performance and extensibility
\o Improve code readability and maintainability
\o Simplify code structure
\endlist
To find the use of a specific symbol in your project:
\list 1
\o In the editor place the cursor on the symbol and select \gui Tools

Rohan Shetty
committed
> \gui C++ > \gui{Find Usages} or press
\key Ctrl+Shift+U.
Qt Creator looks for the symbol in the following locations:
\list
\o Files listed as a part of the project
\o Files directly used by the project files (for example, generated
files)
\o Header files of used frameworks and libraries
\endlist
\o The \gui{Search Results} pane opens and shows the location and
number of instances of the symbol in the current project.
\image qtcreator-refactoring-find.png
\endlist
You can browse the search results in the following ways:
\list
\o To go directly to an instance, double-click the instance in the
\gui{Search Results} pane.
\o To move between instances, click
\inlineimage qtcreator-forward.png
and
\inlineimage qtcreator-back.png
in the \gui{Search Results} pane.
\o To expand and collapse the list of all instances, click
\inlineimage qtcreator-expand.png
.
\o To clear the search results, click \inlineimage qtcreator-clear.png
.
\endlist
The functions available for renaming symbols depend on whether you are

Leena Miettinen
committed
writing C++ or QML code. For QML, you can only rename IDs.
To rename a specific symbol in a Qt project:
\o In the editor, place the cursor on the symbol you would like to
change and select \gui Tools > \gui C++ >

Rohan Shetty
committed
\gui{Rename Symbol Under Cursor} or press \key Ctrl+Shift+R.
The \gui{Search Results} pane opens and shows the location and
number of instances of the symbol in the current project.
\image qtcreator-refactoring-replace.png
\o To replace all selected instances, enter the name of the new symbol
in the \gui{Replace with} text box and click \gui Replace.
To omit an instance, uncheck the check-box next to the instance.
\note This action replaces all selected instances of the symbol in
all files listed in the \gui{Search Results} pane. You cannot
undo this action.

Kavindra Palaraja
committed

Leena Miettinen
committed
\note Renaming local symbols does not open the \gui{Search Results} pane.
The instances of the symbol are highlighted in code and you can edit the
symbol. All instances of the local symbol are changed as you type.

Leena Miettinen
committed
To rename an ID in a Qt Quick project:
\list 1
\o Right-click an ID in the QML code and select
\gui {Rename id}.
\o In the \gui {Rename id} field, enter the new ID.
\endlist

Leena Miettinen
committed

Leena Miettinen
committed
*/

Kavindra Devi Palaraja
committed

Kavindra Palaraja
committed
/*!
\contentspage index.html
\previouspage creator-qml-application.html
\page creator-project-managing.html
\nextpage creator-project-creating.html
\title Managing Projects

Leena Miettinen
committed
One of the major advantages of Qt Creator is that it allows a team of
developers to share a project across different development platforms with a common
tool for development and debugging.
The recommended way to build a project is to use a \l{Using Version Control Systems} {version control system}.
Store and edit only project source files and the .pro and .pri files (for qmake)
or CMakeLists.txt and *.cmake files (for CMake). Do not store
files generated by the build system or Qt Creator, such as makefiles,
.pro.user, and object files. Other approaches are possible,
but we recommend that you do not use network resources, for example.
Qt Creator allows you to specify separate \l{Building for Multiple Targets} {build settings}

Leena Miettinen
committed
for each development platform. By default, \l{glossary-shadow-build}{shadow builds} are used to

Leena Miettinen
committed
keep the build specific files separate from the source.
You can create separate versions of project files to keep platform-dependent
code separate. You can use qmake
\l{http://qt.nokia.com/doc/4.2/qmake-tutorial.html#adding-platform-specific-source-files}{scopes}
to select the file to process depending on which platform qmake is run on.
Items such as open files, breakpoints, and watches are stored in
\l{Managing Sessions}{sessions}. They are not considered to be part of the
information shared across platforms.
Qt Creator is integrated with cross-platform systems for build automation:
qmake and CMake. In addition, you can import generic projects that do not use qmake
or CMake, and specify that Qt Creator ignores your build system.
\o To use \bold{qmake} to build applications, open a \c .pro file. For more
\o To use \bold{CMake} to build applications you need to have CMake version
2.8.0 or later installed. For more information, see
\l{Setting Up a CMake Project}.
\o To use \bold{other build systems} to build applications, specify which files belong to

Leena Miettinen
committed
your project and which include directories or defines you want to pass
to your compiler. For more information, see
Qt Creator provides support for \l{Building and Running Applications}{building and running} Qt applications for
desktop environment and mobile devices. When you install the Nokia Qt SDK,

Leena Miettinen
committed
the build and run settings for the Maemo and Symbian targets are set up
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
automatically. However, you need to install and configure some additional software
on the devices:
\list
\o \l{Setting Up Development Environment for Maemo}.
\o \l{Setting Up Development Environment for Symbian}.
\endlist
\note The only supported build system for mobile applications in Qt
Creator is qmake.
Once your mobile application is ready, you can test it in the Qt Simulator.
You can also connect Maemo and Symbian devices to your development PC and
debug applications on the devices. After you have tested the application,
you can deploy it on mobile devices.
Developing applications for mobile devices is different from developing
desktop applications. For more information, see
\l{Optimizing Applications for Mobile Devices}.
To change the location of the project directory, and to make changes in
the build and run settings, select \gui{Tools} > \gui{Options...} >
\gui{Projects} > \gui{General}.
Through external libraries Qt Creator can support code completion and
syntax highlighting for external libraries as if they were a part of the
current project or the Qt library.
The procedure of adding a library to a project depends on the type of
project, which influences the build system used.
\list
\o For information on adding external libraries to qmake projects, see
\l{Adding External Libraries to a qmake Project}.
\o For information on adding external libraries to CMake projects, see
\l{Adding External Libraries to a CMake Project}.
\endlist
*/
/*!
\contentspage index.html
\previouspage creator-project-managing.html
\page creator-project-creating.html
\nextpage creator-project-qmake.html
You use wizards to create and import several types of projects and files, such
as Qt GUI or console applications and Qt Quick applications.

Leena Miettinen
committed
You can also use
wizards to add individual files to your projects. For example, you can create
the following types of files:
\list
\o Qt resource files, which allow you to store binary files in the
application executable
\o \QD forms and Qt QML files, which specify parts of application user
interfaces
\o C++ class, source, or header files
\endlist
The wizards prompt you to enter the settings needed
for that particular type of project and create the necessary files for you.
To display other types of files in the \gui Projects pane, specify them in
the project file.
\image qtcreator-new-project.png
\section1 Using Project Wizards

Leena Miettinen
committed
\o Select \gui File > \gui{New File or Project} and select the type of your

Leena Miettinen
committed
The contents of the following dialogs depend on the project type.
Follow the instructions of the wizard.

Leena Miettinen
committed
This example uses \gui {Qt Gui Application}.
\o Name the project and set its path. To select the path from a

Leena Miettinen
committed
directory tree, click \gui Browse.
Avoid using spaces and special characters in the project name and
path.
\image qtcreator-intro-and-location.png
\o Specify the name of the class you want to create and using the
drop-down menu select its base class type.
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
\section1 Displaying Additional File Types in Projects Pane
Qt Creator determines whether to display files from the project folder
in the \gui Projects pane depending on the file type (.pro, .pri, .cpp,
.h, .ui, .qrc, and so on). To display other types of files, edit the the
project file. Add filenames as values of the \c {OTHER_FILES} variable.
You can also use wildcards.
For example, the following code specifies that text files are displayed
in the \gui Projects pane:
\code
OTHER_FILES += *.txt
\endcode
This also makes the files available in the \gui Locator.
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
\section1 Adding New Project Wizards
If you have a team working on a large application or several applications,
you might want to standardize the way the team members create projects
and classes.
You can use the wizard templates in the \c {share/qtcreator/templates/wizards}
folder to create your own project and class wizards. Qt Creator looks in the
folder and adds all wizards defined in wizard.xml files to the \gui New dialog
that opens when you select \gui {File > New File or Project}.
In a project wizard, you can specify the files needed in a project.
You can add wizard pages to allow developers to specify settings for the
projcet.
In a class wizard, you can allow developers to specify the class name, base
class, and header and source files for the class.
To see how this works, rename wizard_example.xml as wizard.xml in the helloworld
and listmodels folders. After you restart Qt Creator, the \gui {Custom Classes}
and \gui {Custom Projects} categories appear in the \gui New dialog.
\image qtcreator-custom-project-wizards.png "The New dialog with custom projects and classes"
\section2 Creating Project Wizards
To create a project wizard:
\list 1
\o Make a copy of the \c {share/qtcreator/templates/wizards/helloworld} or
\c {share/qtcreator/templates/wizards/listmodel} folder.
\o Modify the wizard_example.xml file.
\o The following code determines the type of the wizard and its place
in the \gui New dialog:
\code
<wizard version="1" kind="project"
class="qt4project" firstpage="10"
id="A.HelloWorld" category="B.CustomProjects">
\endcode
\list
\o \c version is the version of the file contents. Do not modify this value.
\o \c kind specifies the type of the wizard: \c project or \c class.
\o \c class specifies the type of the project. Currently the only available
type is \c qt4project, which specifies a Qt console project.
\o \c firstpage specifies the place of the new page in the standard project
wizard. The value 10 ensures that the custom page appears after the standard
pages, as the last page of the wizard.
\o \c id is the unique identifier for your wizard. The letter specifies the
position of the wizard within the \c category. The HelloWorld wizard appears
as the first wizard in the second category in the \gui New dialog.
\o \c category is the category in which to place the wizard in the list.
The letter specifies the position of the category in the list in the \gui New
dialog.
\endlist
\o The following code specifies the icon and text that appear in the \gui New
dialog:
\code
<icon>console.png</icon>
<description>Creates a hello-world-project with custom message.</description>
<description xml:lang="de">Erzeugt ein Hello-Welt-Projekt mit einer Nachricht.</description>
<displayname>Hello World</displayname>;
<displayname xml:lang="de">Hallo Welt</displayname>;
<displaycategory>Custom Projects</displaycategory>
<displaycategory xml:lang="de">Benutzerdefinierte Projekte</displaycategory>
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
\endcode
\list
\o \c icon appears next to the \c displayName.
\o \c description appears at the bottom of the \gui New dialog when you
select the display name.
\o \c displayName appears in the \gui New dialog, under the
\c displayCategory.
You can add translations as values for the text elements. Specify the target
language as an attribute for the element. Use locale names (QLocale).
For example, \c {xml:lang="de"}.
\endlist
\o The following code specifies the files to add to the project:
\code
<files>
<file source="main.cpp" openeditor="true" />
<file source="project.pro" target="%ProjectName%.pro" openproject="true" />
\endcode
\list
\o \c source specifies the file to copy to the project. The files must be
located in the wizard folder.
\o \c target specifies the new filename for the file. The \c {%ProjectName%}
variable is replaced with the string that users specify in the \gui Name
field on the first page of the wizard.
\o \c openproject indicates that the file is a project file which is to be opened
after the wizard has finished.
\o \c openeditor indicates that the file is to be opened in an editor after
the wizard has finished.
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
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
\endlist
\o The following code creates a page that specifies settings for the project:
\code
<!-- Create a 2nd wizard page with parameters -->
<fieldpagetitle>Hello World Parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Hallo Welt Parameter</fieldpagetitle>
<fields>
<field mandatory="true" name="MESSAGE">
<fieldcontrol class="QLineEdit" validator='^[^"]+$' defaulttext="Hello world!" />
<fielddescription>Hello world message:</fielddescription>
<fielddescription xml:lang="de">Hallo-Welt-Nachricht:</fielddescription>
</field>
</fields>
\endcode
\list
\o \c fieldpagetitle specifies the title of the page.
\o \c field specifies whether the field is mandatory (\c true or \c false).
You can use the value of the \c name field as a variable in other files (for
example, \c {%MESSAGE%}.
\o \c fieldcontrol specifies the field. \c class specifies the field type.
You can use interface objects from the QWidget class to create fields. This
example uses QLineEdit to create an input field.
\o \c validator specifies a regular expression to check the characters allowed in
the field.
\o \c defaulttext specifies text that appears in the field by default.
\o \c fielddescription specifies the field name that appears on the wizard page.
\endlist
\endlist
\section2 Creating Class Wizards
The widget.xml file for a class wizard is very similar to that for a project
wizard. The differences are discussed below.
To create a class wizard:
\list 1
\o The following code specifies settings for the wizard:
\code
<wizard version="1" kind="class" id="A.ListModel" category="B.CustomClasses">
<description>Creates a QAbstractListModel implementation.</description>
<description xml:lang="de">Erzeugt eine Implementierung von QAbstractListModel.</description>
<displayname>QAbstractListModel implementation</displayname>
<displayname xml:lang="de">Implementierung von QAbstractListModel</displayname>
<displaycategory>Custom Classes</displaycategory>
<displaycategory xml:lang="de">Benutzerdefinierte Klassen</displaycategory>
\endcode
For more information about the elements and their values, see
\l {Creating Project Wizards}.
\o The following code specifies the files to add to the project:
\code
<files>
<file source="listmodel.cpp" target="%ClassName:l%.%CppSourceSuffix%" openeditor="true" />
<file source="listmodel.h" target="%ClassName:l%.%CppHeaderSuffix%" openeditor="true" />
</files>
\endcode
Here, \c target contains the following variables that are used to construct
the filename:
\list
\o \c {%ClassName:l%} is replaced with the value of the \c ClassName field.
The modifier \c l converts the string to lower case, to observe Qt
conventions.
\o \c {%CppSourceSuffix%} is replaced by the default source suffix, which
is defined in Qt Creator in \gui {Tools > Options... > C++ > File Naming}.
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
For example, if users enter \bold MyClass, the filename becomes myclass.cpp
when the project is created.
\o \c {%CppHeaderSuffix%} is replaced by the default header suffix, which
is also defined in \gui {File Naming}. Here, the filename would
become myclass.h.
\endlist
\o The following code creates a page that allows users to select the class
name, base class, and header and source files for the class:
\code
<!-- Create parameter wizard page -->
<fieldpagetitle>ListModel parameters</fieldpagetitle>
<fieldpagetitle xml:lang="de">Parameter des ListModel</fieldpagetitle>
<fields>
<field name="ClassName">
<fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$" defaulttext="MyListModel" />
<fielddescription>Class name:</fielddescription>
<fielddescription xml:lang="de">Klassenname:</fielddescription>
</field>
<field name="Datatype">
<fieldcontrol class="QComboBox" combochoices="QString,int" defaultindex="0" />
<fielddescription>Data type:</fielddescription>
<fielddescription xml:lang="de">Datentyp:</fielddescription>
</field>
</fields>
\endcode
In addition to QLineEdit, QComboBox is used in the class wizard to create
a field. \c combochoices specifies the options in the combobox and
\c defaultindex specifies that QString is the default value.
\endlist
\previouspage creator-project-creating.html
\page creator-project-qmake.html
\nextpage creator-project-cmake.html

Leena Miettinen
committed
The qmake tool helps simplify the build process for development projects
across different platforms. qmake automates the generation of makefiles
so that only a few lines of information are needed to create each makefile.
qmake can be used for any software project, whether it is written in Qt or not.
The qmake tool generates a makefile based on the information in a project
file that is generated by Qt Creator. It can generate makefiles for MinGW,
Microsoft Visual studio, and CSL ARM in Windows, and GNU Compiler Collection
(GCC) in Linux and Mac OS X.
For more information about qmake, see the
\l{http://qt.nokia.com/doc/4.2/qmake-manual.html}{qmake Manual}.
\section1 Selecting the Qt Version
Qt Creator allows you to have multiple versions of Qt installed on
your development PC and use different versions for each of your projects.
If Qt Creator finds \bold qmake in the \c{PATH} environment variable, it uses
that version. The \l{glossary-system-qt}{ qmake 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 \c{PATH} and correctly set up for command line use, you do
not need to manually configure your Qt version.
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
\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 chain in the \gui Toolchain list.
\image qtcreator-qt4-qtversions-win-msvc.png
\endlist
If you are using \bold{Qt for Symbian} and your Symbian 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 \c{PATH} environment variable.
\o To build an application for the emulator (WINSCW toolchain), enter
the path to your Carbide C++ installation directory in
\note You need to have Carbide C++ version 2.0 or later installed.
\section2 Compiling Projects With 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
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 Compiling Projects With Mac OS X
To compile a project in Qt Creator, Mac OS X uses GNU Compiler Collection
(GCC), which is part of Xcode.