QMake 学习记录

  1. contains(variables, value)

    如果变量 variables 包含 value 值,则成功,否则失败。

    contains(variables, value)

    通过判断是否添加某些模块来自动添加对应模块的代码文件。

    contains(QT, network) {
    message("network build")
    HEADERS += network.hpp
    SOURCES += network.cpp
    }

  2. count(variables, value)

    统计 variables 中包含 value 的数量

    count (variables, value)

    应用例子

    options = $$find(CONFIG, "debug")
    $$find(CONFIG, "release")

    count(options, 2) {
    message(Both release and debug specified.)
    }

3. include(filename)

复制代码
# 将指定的文件名包含到当前项目
include(filename)

# 应用例子
!include(core.pri) {
  message("load core.pri failed")
}

4. if (condition)

复制代码
# if 条件判断,和 C++ 的 if 语句一样。

if (condition)

# 应用例子
if (condition) {
    message("hello")
}
  1. for (iter, list)

    循环变量 list 中的所有值

    for(iter, list)

    应用例子

    List = a b c
    for(item, List): message(file = $${item})

    $ 打印输出

    Project MESSAGE: file = a

    Project MESSAGE: file = b

    Project MESSAGE: file = c

  2. system (command)

    执行 shell 命令, 执行命令返回0表示成功,否则失败。

    system("ls /bin"): RET = TRUE

  3. mkpath (dir)

    创建目录, 参数路径。

  4. unset (variable_name)

    将变量名从当前上下文中移除。

9. 信息输出

复制代码
message(string)  # 输出文本信息
warning(string)  # 输出警告信息
error(string)    # 输出错误信息
  1. 信息检测

    估字符串的内容 返回 true

    eval(string)

    应用例子

    eval(TARGETS = app) {
    message($$TARGETS)
    }

相关推荐
sqmeeting1 小时前
QT6 如何在Linux Wayland 桌面系统抓屏和分享屏幕
linux·qt
姓刘的哦5 小时前
Win10上Qt使用Libcurl库
开发语言·qt
hellokandy17 小时前
QT QVersionNumber 比较版本号大小
qt·版本号·qversionnumber
常乐か17 小时前
VS2022+QT5.15.2+OCCT7.9.1的开发环境搭建流程
开发语言·qt·opencascade
誰能久伴不乏20 小时前
Qt TCP 客户端对象生命周期与连接断开问题解析
网络·qt·tcp/ip
kyle~20 小时前
Qt---Qt函数库
开发语言·qt
Forward♞1 天前
Qt——实现”Hello World“、认识对象树与Qt坐标系
开发语言·qt
楚Y6同学1 天前
QT之键盘控制虚拟遥控系统开发总结
开发语言·c++·qt·串口通信
Hemy082 天前
QT_QUICK_BACKEND 环境变量详解(AI生成)
开发语言·qt
小星星·2 天前
局域网远程控制/推流
qt·远程控制·推流