2011-09-27 11:55:44 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-25 16:28:25 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
2011-09-27 11:55:44 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Free Documentation License
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
// 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.
|
|
|
|
|
// **********************************************************************
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
\contentspage index.html
|
|
|
|
|
\previouspage creator-project-managing.html
|
|
|
|
|
\page creator-project-creating.html
|
|
|
|
|
\nextpage creator-project-opening.html
|
|
|
|
|
|
|
|
|
|
\title Creating Projects
|
|
|
|
|
|
2011-12-13 11:52:47 +01:00
|
|
|
Creating a project enables you to:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\o Group files together
|
|
|
|
|
|
|
|
|
|
\o Add custom build steps
|
|
|
|
|
|
|
|
|
|
\o Include forms and resource files
|
|
|
|
|
|
|
|
|
|
\o 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.
|
|
|
|
|
|
|
|
|
|
The wizards create projects that use the Qt build tool, qmake. It is a
|
|
|
|
|
cross-platform system for build automation that helps simplify the build
|
|
|
|
|
process for development projects across different platforms. qmake
|
|
|
|
|
automates the generation of build configurations so that only a few lines
|
|
|
|
|
of information are needed to create each configuration. For more
|
|
|
|
|
information about qmake, see the
|
2012-08-20 12:40:26 +02:00
|
|
|
\l{http://qt-project.org/doc/qt-4.8/qmake-manual.html}{qmake Manual}.
|
2011-12-13 11:52:47 +01:00
|
|
|
|
|
|
|
|
You can modify the build and run settings for qmake projects in the
|
|
|
|
|
\gui Projects mode.
|
|
|
|
|
|
|
|
|
|
Alternatively, you can use the CMake build automation system and set up the
|
|
|
|
|
projects manually. In addition, you can import projects as
|
|
|
|
|
\e {generic projects} that do not use qmake 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 mobile device \l{glossary-development-target}{targets}
|
|
|
|
|
as part of the \QSDK. The build and run settings for the
|
|
|
|
|
installed targets 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.
|
|
|
|
|
|
|
|
|
|
\section1 Using Project Wizards
|
|
|
|
|
|
|
|
|
|
In the first step, you
|
2012-03-02 17:10:51 +01:00
|
|
|
select a template for the project. You can filter templates (1) to view only
|
|
|
|
|
those that apply to a particular target.
|
2011-12-13 11:52:47 +01:00
|
|
|
|
|
|
|
|
\image qtcreator-new-qt-quick-project-wizard.png
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
Next, you select a location for the project and specify settings for it.
|
|
|
|
|
|
2011-12-13 11:52:47 +01:00
|
|
|
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 with the integrated \QMLD.
|
|
|
|
|
|
|
|
|
|
\section1 Selecting Project Type
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
You can use wizards to create following types of projects:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Applications
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\if defined(qcmanual)
|
|
|
|
|
\o Qt GUI Application
|
|
|
|
|
|
|
|
|
|
Use \QD forms to design a Qt widget based user interface for the
|
|
|
|
|
desktop and C++ to implement the application logic
|
|
|
|
|
|
|
|
|
|
\o Mobile Qt Application
|
|
|
|
|
|
|
|
|
|
Use \QD forms to design a Qt widget based user interface for
|
|
|
|
|
mobile devices and C++ to implement the application logic.
|
|
|
|
|
Select this template to develop for devices that support only
|
|
|
|
|
Qt 4.6.x
|
|
|
|
|
\endif
|
|
|
|
|
|
|
|
|
|
\o Qt Quick Application (Built-in Elements)
|
|
|
|
|
|
|
|
|
|
Use built-in QML elements to design Qt Quick based user
|
|
|
|
|
interfaces with a custom look and feel and QML and C++ code to
|
|
|
|
|
implement the application logic
|
|
|
|
|
|
|
|
|
|
\o Qt Quick Application for MeeGo Harmattan
|
|
|
|
|
|
|
|
|
|
Use Qt Quick Components for MeeGo Harmattan to design a user
|
|
|
|
|
interface with the platform look and feel
|
|
|
|
|
|
|
|
|
|
\o Qt Quick Application (from Existing QML File)
|
|
|
|
|
|
|
|
|
|
Convert existing QML applications to projects that you can run
|
|
|
|
|
in \QC or deploy to mobile devices
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Qt Console Application
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
Use a single main.cpp file
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o HTML5 Application
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
Use a QtWebKit view to desigm the user interface and HTML5 and
|
|
|
|
|
C++ code to implement the application logic
|
|
|
|
|
|
|
|
|
|
\o Qt Quick UI
|
|
|
|
|
|
|
|
|
|
Use a single QML file that contains the main view. You can run
|
|
|
|
|
Qt Quick UI projects in the QML Viewer and you need not build
|
|
|
|
|
them. You do not need to have the development environment
|
|
|
|
|
installed on your computer to create and run this type of
|
|
|
|
|
projects
|
|
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\o Libraries
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o C++ Library
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
Shared or static C++ library based on qmake
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Custom QML Extension Plugin
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
C++ plugin that makes it possible to offer extensions
|
|
|
|
|
that can be loaded dynamically into applications by using the
|
|
|
|
|
QDeclarativeEngine class
|
|
|
|
|
|
|
|
|
|
\o \QC Plugin
|
2011-10-06 11:44:15 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\o Other Projects
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\o Qt Unit Test
|
|
|
|
|
|
|
|
|
|
Qt unit tests for features or classes
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\if defined(qcmanual)
|
|
|
|
|
\o Qt Custom Designer Widgets
|
2012-03-02 17:10:51 +01:00
|
|
|
|
|
|
|
|
Custom \QD widget or widget collection
|
2011-09-27 11:55:44 +02:00
|
|
|
\endif
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Plain C/C++ Project
|
|
|
|
|
|
|
|
|
|
Plain C or C++ project that uses qmake but does not use the Qt
|
|
|
|
|
library
|
2011-10-06 11:44:15 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Empty Qt Project
|
|
|
|
|
|
|
|
|
|
Empty Qt project that is based on qmake but does not use any
|
2011-10-06 11:44:15 +02:00
|
|
|
default classes
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Subdirs Project
|
|
|
|
|
|
|
|
|
|
Subprojects that enable you to structure your qmake projects as
|
|
|
|
|
a tree hierarchy
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Non-Qt Projects
|
|
|
|
|
|
|
|
|
|
Plain C or C++ projects that use CMake but do not use the Qt library
|
|
|
|
|
|
|
|
|
|
\o Import Project
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
|
|
|
|
\o Project from version control
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
Import a project from a supported version control system. For more
|
|
|
|
|
information on how version control systems are integrated in
|
2012-03-02 17:10:51 +01:00
|
|
|
\QC, see \l{Using Version Control Systems}
|
|
|
|
|
|
|
|
|
|
\o Import Existing Project
|
|
|
|
|
|
|
|
|
|
Import an existing project that does not use any of the supported
|
|
|
|
|
build systems: qmake, CMake, or Autotools. This enables you to use
|
|
|
|
|
\QC as a code editor
|
|
|
|
|
|
|
|
|
|
\endlist
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
To create a new project, select \gui File > \gui{New File or Project} and
|
|
|
|
|
select the type of your project. The contents of the wizard dialogs depend
|
|
|
|
|
on the project type and the build targets that you select in the
|
|
|
|
|
\gui {Target Setup} dialog. Follow the instructions of the wizard.
|
|
|
|
|
|
|
|
|
|
For examples of creating different types of projects, see
|
2011-12-13 11:52:47 +01:00
|
|
|
\l{Tutorials}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
For more information about creating Qt Quick projects, see
|
|
|
|
|
\l {Creating Qt Quick Projects}.
|
|
|
|
|
|
|
|
|
|
To change the location of the project directory, and to specify settings
|
|
|
|
|
for building and running projects, select \gui{Tools} > \gui{Options} >
|
2011-10-18 11:27:30 +02:00
|
|
|
\gui{Build & Run} > \gui{General}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
To specify build and run settings for different target platforms, select
|
|
|
|
|
\gui Projects.
|
|
|
|
|
|
|
|
|
|
\section1 Adding Files to Projects
|
|
|
|
|
|
|
|
|
|
You can use wizards also to add individual files to your projects.
|
|
|
|
|
You can create the following types of files:
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o C++
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
C++ class, source, or header files that you can use to write the
|
|
|
|
|
application logic in both Qt Quick projects and
|
|
|
|
|
\if defined(qcmanual)
|
|
|
|
|
Qt widget based projects
|
|
|
|
|
\endif
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Qt
|
2011-09-27 11:55:44 +02:00
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\list
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\if defined(qcmanual)
|
2012-03-02 17:10:51 +01:00
|
|
|
\o \QD forms and \QD form classes, which specify parts of user
|
|
|
|
|
interfaces in Qt widget based projects
|
2011-09-27 11:55:44 +02:00
|
|
|
\endif
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\o Qt resource files, which allow you to store binary files in the
|
|
|
|
|
application executable
|
|
|
|
|
|
|
|
|
|
\o QML files, which specify elements in Qt Quick projects
|
|
|
|
|
|
2011-09-27 11:55:44 +02:00
|
|
|
\o JavaScript files that you can use to write the application logic in
|
|
|
|
|
Qt Quick projects
|
|
|
|
|
|
2012-03-02 17:10:51 +01:00
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\o GLSL
|
|
|
|
|
|
|
|
|
|
GLSL files that define fragment and vertex shaders in both Qt Quick
|
|
|
|
|
projects and Qt widget based projects
|
|
|
|
|
|
|
|
|
|
\o General
|
|
|
|
|
|
|
|
|
|
Text files
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
\endlist
|
|
|
|
|
|
|
|
|
|
\section2 Creating C++ Classes
|
|
|
|
|
|
|
|
|
|
The \gui {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 \gui {Class name} field. For example:
|
|
|
|
|
MyNamespace::MySubNamespace::MyClass.
|
|
|
|
|
|
|
|
|
|
\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, click \gui Configure.
|
|
|
|
|
|
|
|
|
|
You can create your own project and class wizards. For more information,
|
|
|
|
|
see \l{Adding New Custom Wizards}.
|
|
|
|
|
|
|
|
|
|
\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
|
2012-08-20 12:40:26 +02:00
|
|
|
\l{http://qt-project.org/doc/qt-4.8/qtopengl.html}{QtOpenGL Module}.
|
2011-09-27 11:55:44 +02:00
|
|
|
|
|
|
|
|
You can use the QGLShader class to compile OpenGL shaders written in the
|
|
|
|
|
OpenGL Shading Language (GLSL) and in the OpenGL/ES Shading Language
|
|
|
|
|
(GLSL/ES). QGLShader and QGLShaderProgram 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 Pane
|
|
|
|
|
|
|
|
|
|
\QC determines whether to display files from the project folder
|
|
|
|
|
in the \gui Projects pane 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 {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.
|
|
|
|
|
|
|
|
|
|
\section1 Adding Subprojects to Projects
|
|
|
|
|
|
2011-12-13 11:52:47 +01:00
|
|
|
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.
|
|
|
|
|
|
2011-09-27 11:55:44 +02:00
|
|
|
When you create a new project, you can add it to another project as a
|
|
|
|
|
subproject in the \gui{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 \gui {File > New File or Project >
|
|
|
|
|
Other Project > Subdirs Project > Choose}.
|
|
|
|
|
|
|
|
|
|
On the \gui Summary page, select \gui {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
|
2012-08-20 12:40:26 +02:00
|
|
|
\l{http://qt-project.org/doc/qt-4.8/qmake-variable-reference.html#subdirs}
|
2011-09-27 11:55:44 +02:00
|
|
|
{SUBDIRS variable}. It also adds all the necessary files for the subproject.
|
|
|
|
|
|
|
|
|
|
To add more subprojects, right-click the project name in the \gui Projects
|
|
|
|
|
pane, and select \gui {New Subproject} in the context menu.
|
|
|
|
|
|
|
|
|
|
To remove subprojects, right-click the project name in the \gui Projects
|
|
|
|
|
pane, and select \gui {Remove Subproject} in the context menu.
|
|
|
|
|
|
|
|
|
|
To specify dependencies, use the \gui{Add Library} wizard. For more
|
|
|
|
|
information, see \l{Adding Libraries to Projects}.
|
2011-12-13 11:52:47 +01:00
|
|
|
|
|
|
|
|
\section1 Related Topics
|
|
|
|
|
|
|
|
|
|
\list
|
|
|
|
|
\o \l{Opening Projects}
|
|
|
|
|
\o \l{Adding Libraries to Projects}
|
|
|
|
|
\o \l{Adding New Custom Wizards}
|
|
|
|
|
\o \l{Setting Up a CMake Project}
|
|
|
|
|
\o \l{Setting Up a Generic Project}
|
|
|
|
|
\endlist
|
|
|
|
|
|
2011-09-27 11:55:44 +02:00
|
|
|
*/
|