/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Creator documentation.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
**
****************************************************************************/

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

    Setting up a new project in \QC is aided by a wizard that guides you
    step-by-step through the project creation process. The wizards prompt you
    to enter the settings needed for that particular type of project and create
    the necessary files for you. You can add your own custom wizards to
    standardize the way subprojects and classes are added 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 are not presented with a
    choice, the project is set up to use qmake.

    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 \l{glossary-buildandrun-kit}{kits} and build and run settings for the
    installed device types are set up automatically. However, you might need to
    install and configure some additional software on the devices to be able to
    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-qt-quick-project-wizard.png

    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 Design mode.

    \section1 Selecting Project Type

    The following table lists the wizard templates for creating projects.

    \table
        \header
            \li Category
            \li Wizard Template
            \li Purpose
        \row
            \li Application (Qt for MCU)
            \li MCU Support Application
            \li Creates an application that uses a subset of Qt QML and
                Qt Quick Controls types (as supported by Qt for MCUs) that
                you can deploy, run, and debug on MCU boards. For more
                information, see \l {Connecting MCUs}.
        \row
            \li {1,2} Application (Qt)
            \li Qt Widgets Application
            \li Uses \QD forms to design a Qt widget based user interface for
                the desktop and C++ to implement the application logic.
        \row
            \li Qt Console Application
            \li Uses a single main.cpp file.
        \row
            \li {1,4} Application (Qt Quick)
            \li Qt Quick Application - Empty
            \li Creates a Qt Quick 2 application project that can contain both
                QML and C++ code. You can build the application and deploy it
                to desktop, embedded, and mobile target platforms.
        \row
            \li Qt Quick Application - Scroll
            \li Uses the \l{ScrollView} component to implement a scrollable
                list view (requires Qt 5.9 or later).
        \row
            \li Qt Quick Application - Stack
            \li Uses the \l{StackView} component to implement a set of pages
                with a stack-based navigation model (requires Qt 5.7 or later).
        \row
           \li Qt Quick Application - Swipe
           \li Uses the \l{SwipeView} component to implement a set of pages
                with a swipe-based navigation model (requires Qt 5.7 or later).
        \row
            \li {1,4} Application (Qt for Python)
            \li Qt for Python - Empty
            \li Creates a \l{https://doc.qt.io/qtforpython/index.html}
                {Qt for Python} application that contains only the main
                code for a QApplication.
        \row
            \li Qt for Python - Window
            \li Creates a Qt for Python application that contains an empty
                window.
        \row
            \li Qt for Python - Window (UI file)
            \li Creates a Qt for Python application that contains an empty
                window with a widget-based UI.
        \row
            \li Qt for Python - Qt Quick Application
            \li Creates a Python project that contains an empty Qt Quick
                Application.
        \row
            \li {1,3} Library
            \li C++ Library
            \li A shared or static C++ library based on qmake.
        \row
            \li Qt Quick 2 Extension Plugin
            \li Creates a C++ plugin that makes it possible to offer extensions
                that can be loaded dynamically into Qt Quick 2 applications
                by using the QQmlEngine class.
        \row
            \li \QC Plugin
            \li Creates a \QC plugin.
        \row
            \li {1,6} Other Project
            \li Qt Custom Designer Widget
            \li Creates a custom \QD widget or widget collection.
        \row
            \li Qt Quick UI Prototype
            \li Creates a \l{Creating Qt Quick UI Projects}{Qt Quick UI project}
                with a single QML file that contains the main view. You can
                preview Qt Quick 2 UI projects in the
                \l{Validating with Target Hardware}{QML Scene preview tool}.
                You do not need to build them, because they do not contain any
                C++ code.

                Use this template only if you are prototyping. You cannot create
                a full application by using this template.

                Qt Quick UI projects cannot be deployed to embedded or mobile
                target platforms. For those platforms, create a Qt Quick
                application instead.
        \row
            \li Auto Test Project
            \li Creates a project with boilerplate code for a Qt or Google
                test. For more information, see \l {Creating Tests}.
        \row
            \li Subdirs Project
            \li Creates a subproject that enables you to structure your qmake
                projects as a tree hierarchy.
        \row
            \li Empty qmake Project
            \li Creates an empty qmake project that is based on qmake but does
                not use any default classes.
        \row
            \li Code Snippet
            \li Creates a qmake project from a code snippet. When fixing bug
                reports that contain a code snippet, you can place the code
                snippet into a project to compile and check it.
        \row
            \li {1,4} Non-Qt Project
            \li Plain C Application
            \li Creates a plain C application that uses qmake, Qbs, or CMake
                but does not use the Qt library.
        \row
            \li Plain C++ Application
            \li Creates a plain C++ application that uses qmake, Qbs, or CMake
                but does not use the Qt library.
        \row
            \li Nim Application (experimental)
            \li Creates a Nim application that uses Nimble, but does not use the
                Qt library. For more information, see \l {Setting Up Nimble}.
        \row
            \li Nimble Application (experimental)
            \li Creates a Nimble application that uses Nimble, but does not use
                the Qt library. For more information, see
                \l {Setting Up Nimble}.
        \row
            \li {1,3} Import Project
            \li Project from version control
            \li Imports a project from a supported version control system, such
                as Bazaar, CVS, Git, Mercurial, or Subversion. For
                more information on how version control systems are integrated
                in \QC, see \l{Using Version Control Systems}.
        \row
            \li Import as qmake or CMake Project (Limited Functionality)
            \li Imports an existing project that does not use any of the
                supported build systems: qmake, Qbs, CMake, or Autotools. The
                template creates a project file, which enables you to use
                \QC as a code editor and as a launcher for debugging and
                analysis tools. However, if you want to build the project,
                you might need to edit the generated project file.
        \row
            \li Import Existing Project
            \li Imports an existing project that does not use any of the
                supported build systems: qmake, Qbs, CMake, or Autotools.
                This enables you to use \QC as a code editor.
    \endtable

    To create a new project, select \uicontrol File > \uicontrol{New File or 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 Adding Files to Projects

    You can use wizards also to add individual files to your projects.
    The following table lists the wizard templates for creating files.

    \table
        \header
            \li Category
            \li Wizard Template
            \li Purpose
        \row
            \li {1,3} C/C++
            \li C++ Class
            \li C++ header and source file for a new class that you can add to
                a C++ project.
        \row
            \li C/C++ Source File
            \li  C++ source file that you can add to a C++ project.
        \row
            \li C/C++ Header File
            \li C++ header file that you can add to a C++ project.
        \row
            \li {1,3} Modeling
            \li State Chart
            \li State Chart XML (SCXML) file that contains boilerplate
                code for state machines. You can use the classes in the
                \l {Qt SCXML} module to embed state machines created from
                the files in Qt applications.
        \row
            \li Model
            \li Universal Modeling Language (UML) style model with a structured
                diagram. However, the model editor uses a variant of UML and
                provides only a subset of properties for specifying the
                appearance of model elements. For more information, see
                \l {Modeling}.
        \row
            \li Scratch Model
            \li Scratch model using a temporary file.
        \row
            \li {1,7} Qt
            \li Qt Item Model
            \li Source and header files that you can use to create classes
                derived from QAbstractItemModel, QAbstractTableModel, or
                QAbstractListModel.
        \row
            \li \QD Form Class
            \li \QD form and a matching class for implementing a UI based
                on Qt widgets.
        \row
            \li \QD Form
            \li \QD form for Qt widget based projects. This is useful
                if you already have an existing class for the UI logic.
        \row
            \li Qt Resource File
            \li Resource file for storing binary files in the application
                executable.
        \row
            \li QML File (Qt Quick 2)
            \li QML file that imports Qt Quick 2.0 for use in Qt Quick projects.
        \row
            \li Qt Quick UI File
            \li \l{UI Files}{UI file} (\e .ui.qml) and the corresponding
                implementation file (\e .qml) for use in Qt Quick projects.
        \row
            \li JS File
            \li JavaScript file that you can use to write the application logic
                in Qt Quick projects.
        \row
            \li {1,4} GLSL
            \li Fragment Shader (OpenGL/ES 2.0)
            \li Fragment shader that generates the final pixel colors for
                triangles, points, and lines rendered with OpenGL. You can use
                it in both Qt Quick projects and Qt widget based projects.
        \row
            \li Vertex Shader (OpenGL/ES 2.0)
            \li Vertex shader that transforms the positions, normals, and
                texture coordinates of triangles, points, and lines rendered
                with OpenGL. You can use it in both Qt Quick projects and Qt
                widget based projects.
        \row
            \li Fragment Shader (Desktop OpenGL)
            \li Fragment shader for use in both Qt Quick projects and Qt
                widget based projects.
        \row
            \li Vertex Shader (Desktop OpenGL)
            \li Vertex shader for use in both Qt Quick projects and Qt
                widget based projects.
       \row
            \li {1,2} General
            \li Empty File
            \li Empty file that you can save with any filename extensio.
        \row
            \li Scratch Buffer
            \li Scratch buffer that uses temporary files. You can
                create this type of files for temporarily storing information
                that you do not intend to save
        \row
            \li Java
            \li Java File
            \li Java class files that you can use to create Java classes.
        \row
            \li {1,2} Python
            \li Python Class
            \li Python class file.
        \row
            \li Python File
            \li Python script file using UTF-8 encoding.
        \row
            \li {1,2} Nim (experimental)
            \li Nim Script File
            \li Empty Nim script file using UTF-8 encoding.
        \row
            \li Nim File
            \li Empty Nim source file using UTF-8 encoding.
    \endtable

    \section2 Creating C++ Classes

    The \uicontrol {C++ Class Wizard} allows you to create a C++ header and source
    file for a new class that you can add to a C++ project. Specify the class
    name, base class, and header and source files for the class.

    The wizard supports namespaces. To use a namespace, enter a qualified
    class name in the \uicontrol {Class name} field. For example:
    \c MyNamespace::MySubNamespace::MyClass. The wizard suggests
    existing namespaces and class names as you type.

    \image qtcreator-cpp-class-wizard.png "Enter Class Name dialog"

    The names of the header and source file are based on the class name. To
    change the default suffix of a file, select \uicontrol Tools > \uicontrol Options >
    \uicontrol {C++} > \uicontrol {File Naming}.

    \image qtcreator-options-cpp-files.png "File Naming tab in Options"

    In the \uicontrol {License template} field, you can use
    \l{Using Variables in Wizards}{predefined wizard variables} to specify the
    path and filename of the license to use in the source and header files.

    You can create your own project and class wizards. For more information,
    see \l{Adding New Custom Wizards}.

    \section2 Creating Resource Files

    \QC supports the \l{The Qt Resource System}{Qt Resource System}, which is a
    platform-independent mechanism for storing files in the application's
    executable.

    \image qtcreator-add-resource-wizard.png "New File or Project dialog"

    The wizard creates a resource collection file (.qrc) that you can manage in
    the resource editor.

    \image qtcreator-add-resource.png "Editing resource files"

    Select \uicontrol {Add Files} to locate and add individual
    files.

    To list the folders and files in ascending alphabetic order in the source
    tree, select \uicontrol {Sort Alphabetically} in the context menu.

    By default, resources are accessible in the application under the same file
    name as they have in the source tree, with a \c{:/} prefix, or by a URL with
    a \c qrc scheme. To specify a path prefix for all files in the \c .qrc file,
    select \uicontrol {Add Prefix} and enter the prefix in the \uicontrol Prefix
    field.

    Some resources need to change based on the user's locale, such as
    translation files or icons. You can specify a locale in the
    \uicontrol Language field.

    Select \uicontrol Remove to remove the selected file from the resource
    collection. In the \uicontrol {Remove File} dialog, select the
    \uicontrol {Delete file permanently} check box to remove the file from
    the file system. To remove files that cannot be found in the file system,
    select \uicontrol {Remove Missing Files}.

    The above functions are also available in the context menu in the
    \uicontrol Projects view.

    \section2 Creating OpenGL Fragment and Vertex Shaders

    Qt provides support for integration with OpenGL implementations on all
    platforms, which allows you to display hardware accelerated 3D graphics
    alongside a more conventional user interface. For more information, see
    \l{Qt GUI}.

    You can use the QOpenGLShader class to compile OpenGL shaders written in the
    OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language
    (GLSL/ES). QOpenGLShader and QOpenGLShaderProgram shelter you from the
    details of
    compiling and linking vertex and fragment shaders.

    You can use \QC code editor to write fragment and vertex shaders
    in GLSL or GLSL/ES. The code editor provides syntax highlighting and code
    completion for the files.

    \image qtcreator-new-opengl-file.png "New OpenGL file wizard"

    \section2 Displaying Additional File Types in Projects View

    \QC determines whether to display files from the project folder
    in the \uicontrol Projects view depending on the file type (.pro, .pri, .cpp,
    .h, .qrc, and so on). To display other types of files, edit the
    project file. Add filenames as values of the \c {DISTFILES} variable.
    You can also use wildcards.

    For example, the following code specifies that text files are displayed
    in the \uicontrol Projects view:

    \code

    DISTFILES += *.txt

    \endcode

    This also makes the files available in the \uicontrol Locator.

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

    When you create a new project, 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 template to build the project.

    To create a root project, select \uicontrol File >
    \uicontrol {New File or 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-new-subproject.png

    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 will directly open the wizard without
    the need to navigate to \uicontrol File > \uicontrol {New File or Project}.

    Keyboard shortcuts for wizards can be set in \uicontrol Tools >
    \uicontrol Options > \uicontrol Environment > \uicontrol Keyboard >
    \uicontrol Wizard. All wizard actions start with \uicontrol Impl there.

    \section1 Related Topics

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

*/
