https://blog.csdn.net/zhangxuechao_/article/details/85049711

下载quazip
https://github.com/stachenov/quazip

也可直接下载我配置好的quazip
https://github.com/zwx230741/quazip.git

加入头文件
在quazip中创建include文件夹
Qt压缩和解压 zip
将zlib头文件拷贝到include文件夹下
Qt压缩和解压 zip
加入动态库文件
在quazip中创建lib文件夹
Qt压缩和解压 zip
将zlib编译好的动态库拷贝到lib文件夹下
Qt压缩和解压 zip
quazip工程配置
修改quazip.pro工程文件。添加头文件路径和动态库路径

INCLUDEPATH += $$PWD/include
LIBS += -L$$PWD/lib -lzlib1

Qt压缩和解压 zip
编译动态库
Qt压缩和解压 zip
不加入头文件,报以下错误
Qt压缩和解压 zip


创建测试工程quazipTest
同理,创建include和lib目录。分别放头文件和动态库文件
Qt压缩和解压 zip
拷贝头文件
从quazip拷贝所有头文件
Qt压缩和解压 zip
拷贝库文件
拷贝刚刚生成的动态库文件。quazipd.dll是Debug生成的,quazipd.dll是quazipd.dll生成的,zlib1.dll是zlib动态库
Qt压缩和解压 zip
quazipTest工程配置
修改quazipTest.pro工程文件。添加头文件路径和动态库路径

INCLUDEPATH += $$PWD/include

CONFIG(debug, debug|release) {
    LIBS += -L$$PWD/lib -lquazipd
} else {
    LIBS += -L$$PWD/lib -lquazip
}

添加压缩解压代码

#include "mainwindow.h"
#include <QApplication>
#include <JlCompress.h>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    JlCompress::compressDir("D:/testzip/a.zip", "D:/testzipdir1");
    JlCompress::extractDir("D:/testzip/a.zip", "D:/testzipdir2");
    
    return a.exec();
}

我测试好的工程:https://github.com/zwx230741/quazipTest.git

相关文章:

  • 2022-01-30
  • 2022-12-23
  • 2021-11-10
  • 2022-12-23
  • 2022-02-05
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-14
  • 2022-02-28
  • 2022-12-23
  • 2021-10-06
  • 2021-09-20
  • 2021-11-30
相关资源
相似解决方案