通过配置项目文件控制编译器分类生成中间文件,中间文件较多时作用较大。
DESTDIR
OBJECTS_DIR
MOC_DIR
- 设置编译时生成moc文件的路径。
- 注:所有QObject派生的类都会生成moc。
RCC_DIR
- 设置编译时资源文件的路径。
- 注:把图片放到qrc里面,使用编译器生成
qrc_xxx.cpp
文件。
UI_DIR
- 设置编译时ui界面文件的路径。
- 注:如存在
xxx.ui
文件则编译器生成名为ui_xxx.h
文件
qmake分类语句
build_type =CONFIG(debug, debug|release) { build_type = debug} else { build_type = release}DESTDIR = $$build_type/outOBJECTS_DIR = $$build_type/objMOC_DIR = $$build_type/mocRCC_DIR = $$build_type/rccUI_DIR = $$build_type/ui
设置分类语句前
设置分类语句后
├─moc│ moc_mainwindow.cpp│ moc_predefs.h│├─obj│ main.obj│ mainwindow.obj│ moc_mainwindow.obj│ qrc_rcc.obj│ TextEdit_resource.res│├─out│ TextEdit.exe│├─rcc│ qrc_rcc.cpp│└─ui ui_mainwindow.h