Qt Creator Manual

Creating a Project

You can use wizards to create following types of projects:

  • Qt Quick Project

    Use QML 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
    • Qt console applications
    • Shared or static C++ libraries
    • Qt unit tests
    • Qt Custom Designer Widgets
    • Subprojects
  • 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 Getting Started.

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... > Projects > 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, .ui, .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

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.

X

Thank you for giving your feedback.

Make sure it is related to this specific page. For more general bugs and requests, please use the Qt Bug Tracker.

[0]; s.parentNode.insertBefore(ga, s); })();