默认的专业文件

qmake 是一个构建自动化工具,随 Qt 框架一起提供。它与 CMakeGNU Autotools 等工具的作用相似,但它专门用于 Qt 。因此,它与 Qt 生态系统很好地集成,尤其是 Qt Creator IDE。

如果你启动 Qt Creator 并选择 File -> New File or Project -> Application -> Qt Widgets 应用程序, Qt Creator 将为你生成一个项目框架以及一个 pro 文件。pro 文件由 qmake 处理以生成文件,文件又由底层构建系统处理(例如 GNU Makenmake )。

如果你将项目命名为 myapp,则会出现“myapp.pro”文件。以下是这样的默认文件的外观,以及用于描述每个 qmake 变量的注释。

# Tells build system that project uses Qt Core and Qt GUI modules.
QT       += core gui

# Prior to Qt 5 widgets were part of Qt GUI module. In Qt 5 we need to add Qt Widgets module.
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

# Specifies name of the binary.
TARGET = myapp

# Denotes that project is an application.
TEMPLATE = app

# List of source files (note: Qt Creator will take care about this list, you don't need to update is manually).
SOURCES += main.cpp\
        mainwindow.cpp

# List of header files (note: Qt Creator will take care about this list).
HEADERS  += mainwindow.h

# List of "ui" files for a tool called Qt Designer, which is embedded into Qt Creator in newer versions of IDE (note: Qt Creator will take care about this list).
FORMS    += mainwindow.ui