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

相关推荐
Tangver3 小时前
QT 9.28
开发语言·qt
m0_689087074 小时前
9.28 Qt界面
开发语言·数据库·qt
江凡心5 小时前
Qt 每日面试题 -5
服务器·数据库·qt·学习·面试
Prejudices7 小时前
QCommandLineParser简介
c++·qt
gma9998 小时前
【Qt】前后端交互---DataCenter类
开发语言·qt
多喝热水-多读书8 小时前
Qt C++设计模式->外观模式
c++·qt·设计模式·外观模式
国中之林8 小时前
【qt】QQ仿真项目1
开发语言·c++·qt·学习·设计模式·ui设计
weixin_439723889 小时前
在ubuntu系统中,如何让其按下物理关机键时,系统不处理,但qt程序能检测到关机键按下的事件,并处理信号
linux·qt·ubuntu
@haihi10 小时前
新手如何使用Qt——方法使用
开发语言·qt