How to create a subdirectory for a project QtCreat

2019-01-16 08:55发布

I would like to divide my Qt project into several directories because it is growing pretty large. However, when I click on browse in QtCreator, there is no 'Add directory' and no such thing in 'Add new'. Can this be done somehow?

8条回答
干净又极端
2楼-- · 2019-01-16 09:06

You can create a sub-directory as long as you have a file you wish to create in it. Go to the parent directory, and "Add" a file to it. "Browse" for the location and create a new folder inside the browse window. Agreed, that is not quite intuitive.

查看更多
你好瞎i
3楼-- · 2019-01-16 09:12

When you create a new Class in your Qt-Project, you can choose the path in this wizard and hereby specify new folders like DAL, BO, UI, ...

查看更多
贪生不怕死
4楼-- · 2019-01-16 09:15

When my 'data' directory only had one sub-directory 'model' it just appeared as "data/model". After adding 'dao' as another sub-directory it displayed data with the traditional +/- manner to reveal model and dao.

查看更多
混吃等死
5楼-- · 2019-01-16 09:17

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

Be careful the folder must exist, 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 !

查看更多
兄弟一词,经得起流年.
6楼-- · 2019-01-16 09:21

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

查看更多
We Are One
7楼-- · 2019-01-16 09:21

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.

查看更多
登录 后发表回答