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)
    }

相关推荐
用户8055336980320 小时前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
xcyxiner20 小时前
DicomViewer (vcpkg Windows和ubuntu编译)7
qt
Quz6 天前
QML Hello World 入门示例
qt
xcyxiner9 天前
DicomViewer (dcmtk读取dcm文件)5
qt
xcyxiner10 天前
DicomViewer (后台线程处理文件)4
qt
xcyxiner10 天前
DicomViewer (添加模型类)3
qt
xcyxiner11 天前
DicomViewer (目录调整) 2
qt
xcyxiner11 天前
dcmtk vtk vtk-dicom(gdcm) 编译(debug) v2
qt
桥田智能13 天前
桥田智能 QT-650S:面向白车身焊装的 800kg 重载快换解决方案
开发语言·qt·系统架构
森G13 天前
75、服务器源码解析---------云视频服务项目
linux·服务器·网络·c++·qt