developer tip

QtCreator 프로젝트의 하위 디렉토리를 만드는 방법은 무엇입니까?

optionbox 2020. 8. 24. 08:10
반응형

QtCreator 프로젝트의 하위 디렉토리를 만드는 방법은 무엇입니까?


Qt 프로젝트가 꽤 커지고 있기 때문에 여러 디렉토리로 나누고 싶습니다. 그러나 QtCreator에서 찾아보기를 클릭하면 'Add directory'가 없으며 'Add new'에는 그런 것이 없습니다. 어떻게 든 할 수 있습니까?


사용할 수있는 한 가지 방법은 각 하위 디렉터리에 대한 프로젝트 포함 파일을 추가하는 것입니다.

Qt Creator는 GUI에 이러한 항목을 중첩 된 방식으로 표시하고 여기에 파일을 추가 할 수 있습니다.

예 :

project.pro에서

include(folder1/include.pri)

folder1 / include.pri에

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

기타


답변 : QtCreator에서 프로젝트의 폴더 또는 하위 디렉토리를 만드는 방법은 무엇입니까?

QT Creator 3.1.x 이전에는 프로젝트를 마우스 오른쪽 버튼으로 클릭 -> " 새로 추가 ... "하고 원하는 폴더의 경로를 변경할 수 있습니다.

Qt 새로 추가 ...

폴더가 존재해야합니다. Qt가 생성하지 않습니다.

새 클래스를 추가하고 기본 폴더 Qt 변경

Qt는 .pro 파일의 경로를 처리합니다.

Qt는 .pro 파일의 경로를 처리합니다.

Qt는 .pro 파일의 경로를 처리합니다.

그게 다야!


같은 문제가 있었고 비교적 간단한 대답을 찾았습니다.

당신이 이동 할 필요 file.cpp에은 newFolder에 - 파일 (> 이름 바꾸기 오른쪽 클릭을)의 이름을 변경하는 것입니다 newFolder\file.cpp.

Qt Creator는 .pro파일을 새 폴더로 이동하고 자동으로 파일을 업데이트 합니다.


버전 1.2.90부터 Qt Creator는 필터 트리 옵션 트리 단순화로 설정되지 않은 경우 프로젝트의 폴더에있는 하위 폴더를 프로젝트 트리의 분기로 표시 합니다.


QT-CREATOR에서 하위 디렉터리를 만드는 것은 불가능한 것 같습니다.

다음을 시도하십시오.

  1. Create a number of sub-directories, with a file-explorer or by command line within the project-folder (for example net/, gui/, test/, data/ ...)!
  2. Move exisiting files into these new folders. And change their paths within the *.proj file!
  3. Create new also files from beginning within the new folders (By AddNew...)!

... QT-CREATOR displays only such folders which contain files that are written with their names into the *.pro or a *.pri file. At root level QT-CREATOR distinguishes between HEADERS, SOURCES, FORMS and OTHER FILES. Within these root folders you can find project-own subfolders, repeatedly. (Not covered in this text is splitting into sub-projects.)


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.


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


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.


Here's what I have done:

  1. In the Project Folder (outside the IDE), create Directories that you'd like to put your code in and move your source files into those directories.

    • "foo"디렉토리에 "foo.cpp"와 "foo.h"를 넣으십시오.
  2. "* .pro"파일에서 이동 한 소스 파일을 참조하는 각 줄로 이동하여 디렉토리 이름을 추가 한 다음 소스 파일 이름 앞에 '/'를 추가합니다.

.pro 2 단계 이전 :

SOURCES += main.cpp \
foo.cpp

HEADERS  += \
foo.h \

.pro 2 단계 이후

SOURCES += main.cpp \ 
foo/foo.cpp

HEADERS += \
foo/foo.h
  1. 테스트 할 프로젝트를 다시 빌드하십시오.

참고 URL : https://stackoverflow.com/questions/1176666/how-to-create-a-subdirectory-for-a-project-qtcreator

반응형