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

相关推荐
鸥梨菌Honevid3 分钟前
Qt自定义控件(1)——QPaintEvent
开发语言·qt
Mr_Xuhhh18 小时前
网络基础(1)
c语言·开发语言·网络·c++·qt·算法
feiyangqingyun21 小时前
Qt音视频开发技巧/推流带旋转角度/rtsprtmp推流/保存文件到MP4/拉流解析旋转角度
qt·音视频·qt旋转角度推流
清醒的兰1 天前
Qt 基于TCP套接字编程
网络·qt·tcp
mahuifa10 天前
PySide环境配置及工具使用
python·qt·环境配置·开发经验·pyside
小灰灰搞电子10 天前
Qt PyQt与PySide技术-C++库的Python绑定
c++·qt·pyqt
Echo``11 天前
12.OpenCV—基础入门
开发语言·c++·人工智能·qt·opencv·计算机视觉
智驾11 天前
QML革命:下一代GUI开发的核心优势详解
qt·qml
五_谷_丰_登11 天前
mongoDB服务本地化部署
数据库·c++·qt·mongodb
tangchao340勤奋的老年?11 天前
Qt QMap数据清除测试(验证QMap内存正确释放方法)
开发语言·qt