QT_DISCARD_FILE_CONTENTS

指定在资源文件系统中,给定的文件应为空。

该属性自 Qt 6.6 起引入。

注意:此 属性处于技术预览阶段,未来版本中可能会发生变化。

在使用基于目标的qt_add_resources()或qt_add_qml_module() 变体时,将此属性设置为 `TRUE ` 会导致在创建资源文件系统时省略文件内容。文件名将被保留。

如果您希望从二进制文件中移除 QML 源代码,此功能将非常有用。

注意:若从 二进制文件中省略 QML 源代码,QML 引擎将不得不依赖由qmlcachegen或qmlsc 生成的编译单元。这些编译单元与构建时所用的特定 Qt 版本紧密关联。若更改应用程序所使用的 Qt 版本,这些编译单元将无法再被加载。

另请参阅 《Qt 资源系统》。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.