Table of Contents

Project structure

There are two views you can take toward how Qt projects are structured: the file view and the workflow view. Depending on how your brain works and/or the issue you are trying to understand, one of these will work better than the other. In all probability, both will be useful at some point.

The file view

A Qt project is a collection of project description files, source code files, resource files, and binary output files. Some of these files must be explicitly generated using a text editor or similar tool, others are automatically generated by the build process.1)

Project description files

Explicitly generated

Automatically generated

Source files

Explicitly generated

Automatically generated

Resources

Explicitly generated

Automatically generated

Binary output

The workflow view

The typical Qt project workflow consists of the following major phases: creating a project, adding files to a project, building and testing a project. These are discussed below.2)

Creating a project

  1. Create a new directory to contain your project that carries the name of your project.
  2. Create a main.cpp file in that directory that contains some skeleton code (e.g., HelloWorld).
  3. Execute
    qmake -project

    in a terminal shell in the project directory. This will generate a {directory-name}.pro project description file.

Adding files

  1. Create the desired *.h, *.cpp, *.ui, and *.qrc source files in the project directory and edit to your heart's content.
  2. Edit {directory-name}.pro to reflect the added files.
  3. Run
    qmake

    to generate a new Makefile, debug and release sub-directories (if needed), and and other support files.

Notes:

Building and testing

  1. If you did not configure the {directory-name}.pro file to build both release and debug versions, build the project by executing
    make

    in the project directory. If you did specify release and/or debug builds in {directory-name}.pro, then run

    make release

    or

    make debug

    depending on what you want.

  2. Launch your application by executing
    ./{directory-name}

    in the project directory (or use your file manager to launch the executable, or load the executable into a debugger or …).

Notes:

1)
The explicit/automatic dichotomy holds true whether you are using an IDE or a simple command line based environment. However, an IDE will typically manage the explicit generation of may of the files for you (e.g., *.pro files).
2)
These phases hold true whether you are using a IDE or a simple command line based environment. However, an IDE will typically manage many of these tasks for you.