How to create a subdirectory for a project QtCreator?

Answer : How to create a folder or a subdirectory for a project in QtCreator?

Prior to QT Creator 3.1.x, you can right-click on your project -> "add new..." and change the path to the folder you want.

Qt add new...

The folder must exists, Qt will not create it for you.

Add a new class and change the default folder Qt

Qt takes care of the path in your .pro file.

Qt takes care of the path in your .pro file

Qt takes care of the path in your .pro file

That's it !


Starting from version 1.2.90 Qt Creator shows subfolders which exist in project's folder as branches in project's tree if only Filter tree option is not set to Simplify tree.


Just had the same issue, and found out a relatively simple answer.

All you need to do to move file.cpp to newFolder is to rename the file (right click -> Rename) to newFolder\file.cpp.

Qt Creator will move it to the new folder and automatically update the .pro file.


One method you could use is to add a project include file for each sub directory.

Qt Creator displays these in the GUI in a nested fashion, and allows you to add files to them.

e.g.

in project.pro

include(folder1/include.pri)

in folder1/include.pri

HEADERS += MyClass.h
SOURCES += MyClass.cpp

etc