Qt Creator Documentation

Creating a Project

You use wizards to create and import several types of projects and files, such as Qt GUI or console applications and Qt Quick applications. You can use wizards also to add individual files to your projects.

The wizards prompt you to enter the settings needed for that particular type of project and create the necessary files for you. To display other types of files in the Projects pane, specify them in the project file.

To change the location of the project directory, and to make changes in the build and run settings, select Tools > Options... > Projects > General.

Using Project Wizards

To create a new project:

  1. Select File > New File or Project and select the type of your project.

    The contents of the following dialogs depend on the project type. Follow the instructions of the wizard. This example uses Qt Gui Application.

  2. Name the project and set its path, and then click Next.

    Do not use spaces and special characters in the project name and path.

  3. Select the Qt versions to use as build targets for your project, and click Next.

    "Qt Versions dialog"

    Note: If you have only one Qt version installed, this dialog is skipped.

  4. Specify the name of the class you want to create and using the drop-down menu select its base class type.

    Note that the Header file, Source file and Form file fields are automatically updated as you name your class.

  5. Review the project settings.

    To create the project, click Finish.

Adding Files to 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 QML files, which specify parts of application user interfaces
  • C++ class, source, or header files
  • 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.

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, you first have to edit the .pro file of the parent project to specify that qmake uses the subdirs template to build the project.

The subdirs template creates a Makefile for building subprojects. They can be located either in subdirectories of the project directory or in any other directory. The location of the targets is specified using the SUBDIRS variable. If the project file has the same name as the directory, you can just specify the directory name. If the project name and directory name are different, you must specify the project file name (.pro).

For more information on the SUBDIRS variable, see the qmake Variable Reference.

For example, the following code specifies that plugin_coreplugin/plugin_coreplugin.pro and mylogin.pro belong to the project:

 TEMPLATE  = subdirs

 SUBDIRS = plugin_coreplugin \
 ../another/plugin/myplugin.pro

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

[Previous: Managing Projects] [Next: Opening a Project]

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.

s.parentNode.insertBefore(ga, s); })(); -->