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

相关推荐
Felix_One5 天前
Qt 串口通信避坑指南:QSerialPort 的 5 个常见问题
qt
blasit8 天前
笔记:Qt C++建立子线程做一个socket TCP常连接通信
c++·qt·tcp/ip
范特西.i13 天前
QT聊天项目(8)
开发语言·qt
枫叶丹413 天前
【Qt开发】Qt界面优化(七)-> Qt样式表(QSS) 样式属性
c语言·开发语言·c++·qt
十五年专注C++开发13 天前
Qt deleteLater作用及源码分析
开发语言·c++·qt·qobject
kangzerun13 天前
SQLiteManager:一个优雅的Qt SQLite数据库操作类
数据库·qt·sqlite
金刚狼8813 天前
qt和qt creator的下载安装
开发语言·qt
追烽少年x13 天前
Qt中使用Zint库显示二维码
qt
谁刺我心13 天前
qt源码、qt在线安装器镜像下载
开发语言·qt
金刚狼8813 天前
在qt creator中创建helloworld程序并构建
开发语言·qt