当前位置:网站首页>Qt 学习(二) —— .pro文件详解
Qt 学习(二) —— .pro文件详解
2022-07-27 09:42:00 【万俟淋曦】
一、.pro文件内容解释
.pro文件是qmake用来生成makefile文件的中间文件。
新建简单Qt工程,默认生成 .pro文件内容如下,解释见注释:
# [QT+= ]语法,定义该工程包含的Qt模块
QT += core gui
# 由于Qt5将widgets模块从gui模块独立出来了,所以定义Qt主版本大于4就要包含widgets模块
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
# 编译宏,使用c++17编译
CONFIG += c++17
# 也可以 CONFIG -=
# CONFIG -= debug 不编译debug类型
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# 需要编译的源文件路径(项目根目录的相对路径)
SOURCES += \
main.cpp \
widget.cpp
# 需要编译的头文件路径(项目根目录的相对路径)
HEADERS += \
widget.h
# 需要编译的ui文件路径(项目根目录的相对路径)
FORMS += \
widget.ui
# 只知道是设置目标可以执行文件路径的,具体语法看不懂,如果你知道欢迎评论区留言
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
除工程默认的一些字段,.pro文件还有一些其他字段:
# 目标可执行文件的名称,不指定默认为工程名
TARGET = exe_name
# 目标可执行文件的存放目录,不指定默认为realse目录
# 几个指定目录的符号:
# 宏 $$PWD 代表当前目录和 ./ 等效
# ../ 代表上一级目录
DESTDIR = exe_dir
# 编译宏开关,根据不同宏作不同的编译
DEFINES += defines
# obj文件目录,即 .o 文件
OBJECTS_DIR = obj_dir
# 资源文件路径,包括图片、音频等(项目根目录的相对路径)
RESOURCES += res.rc
# 链接库路径(项目根目录的相对路径)
DEPENDPATH += depend_dir
# 链接库文件(项目根目录的相对路径)
LIBS += -Llib_name
# 也可以直接写带路径的链接库文件
LIBS += -Llib_dir_name
# 引用库头文件路径(项目根目录的相对路径)
INCLUDES += include_dir
# 项目使用的模板类型
TEMPLATE = app
TEMPLATE = lib
二、qmake生成makefile过程
to be continue…
边栏推荐
- 通俗易懂!图解Go协程原理及实战
- 拟搬迁!211中国石油大学(华东)新校区,正式启用!
- 给自己写一个年终总结,新年快乐!
- 7/26 thinking +dp+ suffix array learning
- Redis 为什么这么快?Redis 的线程模型与 Redis 多线程
- July training (day 16) - queue
- Qt | 关于Qt Creator打开项目编译不过的问题
- 在Centos 7安装Mysql 5.7.27后无法启动?(语言-bash)
- [Wuhan University of technology] information sharing for the preliminary and second examinations of postgraduate entrance examination
- July training (day 15) - depth first search
猜你喜欢

C # set different text watermarks for each page of word

通俗易懂!图解Go协程原理及实战
![[cloud native • Devops] master the container management tool rancher](/img/6f/50deaf053c86486e52d2c2c7310ed2.png)
[cloud native • Devops] master the container management tool rancher

What happens if the MySQL disk is full? I really met you!

拜托!面试请不要再问我 Ribbon 的架构原理

食品安全 | 菜板环境很重要,这些使用细节你知道吗?

Sentinel 万字教程 | 文末送书

习题 --- 快排、归并、浮点数二分

Understand chisel language. 26. Chisel advanced input signal processing (II) -- majority voter filtering, function abstraction and asynchronous reset

省应急管理厅:广州可争取推广幼儿应急安全宣教经验
随机推荐
Quickly apply JS to customize the effect of lunar phase change
拜托!面试请不要再问我 Ribbon 的架构原理
Introduction to memory wall
Brush the title "sword finger offer" day04
I haven't delivered books for a long time, and I feel uncomfortable all over
Lua function nested call
Interview Essentials: shrimp skin server 15 consecutive questions
走向人生巅峰....
为什么微服务一定要有API网关?
7/26 思维+dp+后缀数组的学习
语音直播系统——开发推送通知需要遵守的原则
去 OPPO 面试,被问麻了
swagger-editor
在Centos 7安装Mysql 5.7.27后无法启动?(语言-bash)
Google Earth Engine APP——利用S2影像进行最大值影像合成分析
Voice live broadcast system - Principles to be followed in developing push notifications
July training (day 23) - dictionary tree
Annotation and reflection
Understand chisel language. 23. Chisel sequential circuit (III) -- detailed explanation of chisel shift register
快应用JS自定义月相变化效果