aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/projects/creator-only/creator-projects-creating.qdoc
blob: 6ea2b20b036f0825255cc76d0a86abcf6e3cd300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
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
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

// **********************************************************************
// 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.
// **********************************************************************

/*!
    \previouspage creator-project-managing.html
    \page creator-project-creating.html
    \nextpage creator-file-creating.html

    \title Creating Projects

    Creating a project enables you to:

    \list

        \li Group files together

        \li Add custom build steps

        \li Include forms and resource files

        \li Specify settings for running applications

    \endlist

    When you set up a new project in \QC, a wizard guides you step-by-step
    through the process. The wizard templates prompt you to enter the settings
    that you need for that particular type of project and create
    the necessary files for you. You can add your own custom wizards to
    standardize the way of adding subprojects and classes to a project.

    Most \QC project wizards enable you to choose the build system to use for
    building the project: qmake, CMake, or Qbs. If you do not get to choose,
    the project uses qmake as the build system.

    You can use wizards also to create plain C or C++ projects that use
    qmake, Qbs, or CMake, but do not use the Qt library.

    In addition, you can import projects as \e {generic projects} that do not
    use qmake, Qbs, or CMake. This enables you to use \QC as a code editor and
    to fully control the steps and commands used to build the project.

    You can install tools for \l{glossary-device}{devices} as part of Qt distributions.
    The installers create \l{glossary-buildandrun-kit}{kits} and specify build
    and run settings for the installed device types. However, you might need to
    install and configure some additional software on the devices to be able to
    \l{Connecting Devices}{connect} to them from the development PC.

    \include creator-projects-build-systems.qdocinc build systems

    \section1 Using Project Wizards

    In the first step, you select a template for the project. You can filter
    templates (1) to view only those that apply to a particular target platform.

    \image qtcreator-new-project.webp {New Project dialog}

    Next, you select a location for the project and specify settings for it.

    When you have completed the steps, \QC automatically generates the project
    with required headers, source files, user interface descriptions and project
    files, as defined by the wizard.

    For example, if you choose to create a Qt Quick application, \QC generates a
    QML file that you can modify in the \uicontrol Edit mode.

    \section1 Selecting Project Type

    The following table lists the types of wizard templates that you can use
    for creating projects. The \uicontrol {New Project} dialog shows detailed
    information about each project wizard template.

    \table
        \header
            \li Category
            \li Purpose
        \row
            \li Application
            \li Use many UI technologies (Qt Widgets and Qt Quick) and
                programming languages (C++, QML, and Python) to create
                applications for different purposes that you can run on
                many target platforms (desktop, mobile, and embedded).
        \row
            \li Library or plugin
            \li Create a shared or static C++ library, a C++ plugin for Qt Quick
                application extensions, or a \QC plugin.
        \row
            \li Other project
            \li Create custom \l{Developing Widget Based Applications}{\QD}
                 widgets or widget collections,
                \l{Qt Quick UI Projects}{Qt Quick UI projects},
                \l {Creating Tests}{auto-test projects},
                \l{Adding Subprojects to Projects}{subprojects},
                empty qmake projects, or qmake projects for testing
                code snippets.
        \row
            \li Non-Qt project
            \li Create plain C or C++ applications or \l {Setting Up Nimble}
                {Nim or Nimble} applications (experimental)
        \row
            \li Imported project
            \li Import projects from a supported \l{Using Version Control Systems}
                {version control system}, such as Bazaar, CVS, Git, Mercurial, or
                Subversion.

                You can also import existing projects that do not use any of the
                supported build systems to use \QC as a code editor and as a
                launcher for debugging and analysis tools.
        \row
            \li Squish
            \li Create new \l {Using Squish}{Squish test suites}.

    \endtable

    To create a new project, select \uicontrol File > \uicontrol{New Project} and
    select the type of your project. The contents of the wizard dialogs depend
    on the project type and the \l{glossary-buildandrun-kit}{kits} that you select in the
    \uicontrol {Kit Selection} dialog. Follow the instructions of the wizard.

    For examples of creating different types of projects, see
    \l{Tutorials}.

    For more information about creating Qt Quick projects, see
    \l {Creating Qt Quick Projects}.

    \include creator-python-project.qdocinc python project wizards

    \section1 Specifying Project Contents

    A project can have files that should be:

    \list
        \li Compiled or otherwise handled by the build
        \li Installed
        \li Not installed, but included in a source package created with
            \c {make dist}
        \li Not installed, nor be part of a source package, but still be known
            to \QC
    \endlist

    \QC displays all files that you declare to be part of the project by the
    project files in the \l Projects view. It sorts the files into categories
    by file type (.cpp, .h, .qrc, and so on). To display additional files, edit
    the project file. Alternatively, you can see all the files in a project
    directory in the \l {File System} view.

    Declaring files as a part of the project also makes them visible to the
    \l{Searching with the Locator}{locator} and \l{Advanced Search}
    {project-wide search}.

    \section2 CMake Projects

    When using CMake, you can specify additional files for a project by either
    adding them as sources or installing them.

    In the CMakeLists.txt file, define the files as values of the
    \l{CMake: target_sources command}{target_sources} command using
    the \c PRIVATE property, for example.

    You can prevent CMake from handling some files, such as a .cpp
    file that should not be compiled. Use the \l{CMake: set_property command}
    {set_property} command and the \l{CMake: HEADER_FILE_ONLY}
    {HEADER_FILE_ONLY} property to specify such files. For example:

    \badcode
    set_property(SOURCE "${files}" PROPERTY HEADER_FILE_ONLY ON)
    \endcode

    Alternatively, to install the files, use the \l {CMake: install command}
    {install} command with the \c FILES or \c DIRECTORY property.

    \section2 qmake Projects

    Use the following variables in the .pro file:

    \list
        \li \c SOURCES and \c HEADERS for files to compile
        \li \c INSTALLS for files to install
        \li \c DISTFILES for files to include in a source package
        \li \c OTHER_FILES for files to manage with \QC without
            installing them or including them in source packages
    \endlist

    For example, the following value includes text files in the source package:

    \badcode

    DISTFILES += *.txt

    \endcode

    \section1 Adding Subprojects to Projects

    In addition to Qt libraries, you can link your application to other
    libraries, such as system libraries or your own libraries. Further, your
    own libraries might link to other libraries. To be able to compile your
    project, you must add the libraries to your project. This also enables
    code completion and syntax highlighting for the libraries.
    The procedure of adding a library to a project depends on the build
    system that you use.

    \section2 CMake Projects

    You can add CMakeLists.txt files to any project by using the
    \l{https://cmake.org/cmake/help/latest/command/add_subdirectory.html}
    {add_subdirectory} command. The files can define complete projects that
    you include into the top-level project or any other CMake commands.

    \section2 qmake Projects

    When you create a new project and select qmake as the build system,
    you can add it to another project as a subproject in the
    \uicontrol{Project Management} dialog. However, the root project
    must specify that qmake uses the \c subdirs \l{TEMPLATE}{template} to
    build the project.

    To create a root project, select \uicontrol File >
    \uicontrol {New Project} > \uicontrol {Other Project} >
    \uicontrol {Subdirs Project} > \uicontrol Choose.

    On the \uicontrol Summary page, select \uicontrol {Finish & Add Subproject} to create
    the root project and to add another project, such as a C++ library.

    The wizard creates a project file (.pro) that defines a \c subdirs template
    and the subproject that you add as a value of the \l{Variables#subdirs}
    {SUBDIRS variable}. It also adds all the necessary files for the subproject.

    To create more subprojects, right-click the project name in the
    \uicontrol Projects view to open the context menu, and select
    \uicontrol {New Subproject}. Follow the steps in the
     \uicontrol {New Subproject} wizard to create a subproject.

    \image qtcreator-project-qt-quick.webp {New Project dialog}

    To add an existing project as a subproject, select
    \uicontrol {Add Existing Projects} in the context menu.
    In the file browser dialog, locate your subproject.

    To remove subprojects, right-click the project name in the \uicontrol Projects
    view, and select \uicontrol {Remove Subproject} in the context menu.

    To specify dependencies, use the \uicontrol{Add Library} wizard. For more
    information, see \l{Adding Libraries to Projects}.

    \section1 Binding Keyboard Shortcuts to Wizards

    If you use a wizard regularly, you can bind a custom keyboard shortcut to
    it. Triggering this keyboard shortcut directly opens the wizard, so you do
    not need to navigate to \uicontrol File > \uicontrol {New File} or
    \uicontrol {New Project}.

    Set keyboard shortcuts for wizards in \uicontrol Edit >
    \uicontrol Preferences > \uicontrol Environment > \uicontrol Keyboard >
    \uicontrol Wizard. All wizard actions start with \uicontrol Impl there.

    \section1 Related Topics

    \list
        \li  \l{Creating Files}
        \li  \l{Opening Projects}
        \li  \l{Adding Libraries to Projects}
        \li  \l{Adding New Custom Wizards}
        \li  \l{Build Systems}
    \endlist

*/