Qt Creator Manual

Creating Projects

Creating a project enables you to:

  • Group files together
  • Add custom build steps
  • Include forms and resource files
  • Specify settings for running applications

Setting up a new project in Qt Creator 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 qmake Manual.

You can modify the build and run settings for qmake projects in the Projects mode.

Alternatively, you can use the CMake build automation system and set up the projects manually. In addition, you can import projects as generic projects that do not use qmake or CMake. This enables you to use Qt Creator as a code editor and to fully control the steps and commands used to build the project.

To develop applications for Symbian devices, you use qmake and the local Symbian compiler (on Windows) or qmake and a compilation service at Nokia Developer (on Linux and Mac OS) to build the applications for the Symbian devices target. The interface to the compilation service, Remote Compiler, is installed as a part of the Qt SDK. For more information, see Building with Remote Compiler. You can install mobile device targets as part of the Qt SDK. 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.

Using Project Wizards

In the first step, you select the type of the project. Next, you select a location for the project and specify settings for it.

When you have completed the steps, Qt Creator 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, Qt Creator generates a QML file that you can modify with the integrated Qt Quick Designer.

Selecting Project Type

You can use wizards to create following types of projects:

  • Qt Quick Project

    Use QML elements or Qt Quick Components to define the user interface and, optionally, C++ or JavaScript to define the application logic.

  • Qt Widget Project

    Use Qt Designer forms to define a Qt widget based user interface and C++ to define the application logic

  • Other Project
    • HTML5 based applications that contain both HTML5 and C++ code and include a WebKit view
    • Qt console applications that contain a single main.cpp file with a stub implementation
    • Shared or static C++ libraries
    • Plain C or C++ projects that use qmake but do not use the Qt library
    • Qt unit tests for features or classes
    • Qt Custom Designer Widgets
    • Qt Creator plugins
    • Empty Qt projects that are based on qmake but do not use any default classes
    • Subprojects to structure your qmake projects as a tree hierarchy
  • Project from Version Control

    Import a project from a supported version control system. For more information on how version control systems are integrated in Qt Creator, see Using Version Control Systems.

To create a new project, select File > 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 Target Setup dialog. Follow the instructions of the wizard.

For examples of creating different types of projects, see Tutorials.

For more information about creating Qt Quick projects, see Creating Qt Quick Projects.

To change the location of the project directory, and to specify settings for building and running projects, select Tools > Options > Build & Run > General.

To specify build and run settings for different target platforms, select Projects.

Adding Files to Projects

You can use wizards also to add individual files to your projects. You can create the following types of files:

  • Qt resource files, which allow you to store binary files in the application executable
  • Qt Designer forms and Qt Designer form classes, which specify parts of user interfaces in Qt widget based projects
  • QML files, which specify elements in Qt Quick projects
  • GLSL files that define fragment and vertex shaders in both Qt Quick projects and Qt widget based projects
  • C++ class, source, or header files that you can use to write the application logic in both Qt Quick projects and Qt widget based projects
  • JavaScript files that you can use to write the application logic in Qt Quick projects
  • Text files

Creating C++ Classes

The 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 Class name field. For example: MyNamespace::MySubNamespace::MyClass.

"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 Configure.

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

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 QtOpenGL Module.

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 Qt Creator 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.

"New OpenGL file wizard"

Displaying Additional File Types in Projects Pane

Qt Creator determines whether to display files from the project folder in the 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 OTHER_FILES variable. You can also use wildcards.

For example, the following code specifies that text files are displayed in the Projects pane:

 OTHER_FILES += *.txt

This also makes the files available in the Locator.

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 Project Management dialog. However, the root project must specify that qmake uses the subdirs template to build the project.

To create a root project, select File > New File or Project > Other Project > Subdirs Project > Choose.

On the Summary page, select 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 subdirs template and the subproject that you add as a value of the SUBDIRS variable. It also adds all the necessary files for the subproject.

To add more subprojects, right-click the project name in the Projects pane, and select New Subproject in the context menu.

To remove subprojects, right-click the project name in the Projects pane, and select Remove Subproject in the context menu.

To specify dependencies, use the Add Library wizard. For more information, see Adding Libraries to Projects.

Related Topics