gpt4 book ai didi

Qt:*.pro 与 *.pri

转载 作者:行者123 更新时间:2023-12-03 05:17:16 26 4
gpt4 key购买 nike

qmake 的*.pro*.pri 配置文件有什么区别?

*.pro 文件中应包含哪些内容,*.pri 文件中应包含哪些内容?

最佳答案

它们的目标重用之间有一个主要区别:

.pro

这通常称为项目文件

.pri

这通常称为项目包含文件

正如您在它们的名称中看到的,主要区别在于.pri文件应该是包含文件。本质上,这类似于在编程语言中包含模块以共享功能。

您将能够将常用设置和代码写入 .pri文件并包含来自多个 .pro 的文件需要时归档。这是您在实践中使用它的方式:

foo.pri

FOO = BAR

hello.pro

...
include($$PWD/foo.pri)
...

世界.pro

...
include($$PWD/foo.pri)
...

这样,通用性就可以在hello.pro中使用。以及 world.pro 。在这种情况下,它并没有多大区别,但是当共享功能变得更长时,它会为您节省一些编写以及同步、错误修复等工作。

您甚至可以包含 .pri文件在另一个.pri如果您愿意的话可以归档。您还可以包括 .pri不同子项目中的文件等等,非常好。

但是,.pro 的语法是相同的。和.pri文件。最后,您将在.pro上运行qmake。文件,如果您不存在项目文件并且打算使用 qmake -project,那么这也是 qmake 为您生成的内容。 .

您可以阅读有关包含函数的更多信息 in here :

include(filename)

Includes the contents of the file specified by filename into the current project at the point where it is included. This function succeeds if filename is included; otherwise it fails. The included file is processed immediately.

You can check whether the file was included by using this function as the condition for a scope.

为了完整起见,还有 .prf 项目功能文件.prl 项目链接器文件,但作为最终用户,您现在不需要处理它。

关于Qt:*.pro 与 *.pri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8358627/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com