且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将 zlib 添加到现有的 qt 安装

更新时间:2022-02-02 08:05:58

zlib 包含在核心 Qt 库中.如果你想在 Qt 程序中使用 zlib 函数,你只需要包含在 src/3rdparty/zlib 中的 zlib.h.见例如src/corelib/tools 中 QByteArray 的实现.

zlib is contained in the core Qt libraries. If you want to use the zlib functions in a Qt program, you only have to include zlib.h which is in src/3rdparty/zlib. See e.g. the implementation of QByteArray in src/corelib/tools.

如果您想使用 quazip,只需将库添加到您的项目中.它基于 Qt 库.注意构建与您的 Qt 安装相对应的正确 qyazip 库.

If you want to use quazip, just add the library to your project. It is based on the Qt libraries. Take care to build the correct qyazip library that corresponds to your Qt installation.

通过将以下行添加到项目文件中,您可以获得正确的包含路径:

You get the correct include path by adding the following line to your project file:

INCLUDEPATH += $$[QT_INSTALL_PREFIX]/src/3rdparty/zlib

对于 Qt5,请参阅 Thorbjørn 的评论:使用 #include 就足够了.

For Qt5, see Thorbjørn's comment: it is sufficient to use #include <QtZlib/zlib.h>.