qt 5.15.2压缩和解压缩功能

qt 5.15.2压缩和解压缩功能

主要是添加qt项目文件.pro内容:
这里要先下载quazip的c++项目先编译后引入到本项目中/zip目录下

INCLUDEPATH +=./zip
CONFIG(debug, debug|release) {
    win32:win32-g++: PRE_TARGETDEPS += $$PWD/zip/libquazipd.a
    win32:win32-g++: LIBS += -L$$PWD/zip/ -l quazipd
} else {
    win32:win32-g++: PRE_TARGETDEPS += $$PWD/zip/libquazip.a
    win32:win32-g++: LIBS += -L$$PWD/zip/ -l quazip
}

完整的qt项目文件.pro内容如下所示:

QT = core

INCLUDEPATH +=./zip
CONFIG(debug, debug|release) {
    win32:win32-g++: PRE_TARGETDEPS += $$PWD/zip/libquazipd.a
    win32:win32-g++: LIBS += -L$$PWD/zip/ -l quazipd
} else {
    win32:win32-g++: PRE_TARGETDEPS += $$PWD/zip/libquazip.a
    win32:win32-g++: LIBS += -L$$PWD/zip/ -l quazip
}

CONFIG += c++17 cmdline

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
        main.cpp

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

DISTFILES += \
    zip/libquazipd.a \
    zip/quazipd.dll

HEADERS += \
    zip/JlCompress.h \
    zip/quazip.h \
    zip/quazipfile.h \
    zip/quazipfileinfo.h

根目录下zip目录情况如下所示:

在这里插入图片描述
main.cpp

#include <QCoreApplication>
#include "JlCompress.h"
#include <iostream>

int printf(QString line)
{
    std::cout<<line.toStdString()<<std::endl;
}
int printf(int line)
{
    std::cout<<line<<std::endl;
}

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    //解压缩
    JlCompress::extractDir("C:\\data\\obj\\Tile_+006_+006_OBJ.zip","C:\\data\\obj\\Tile_+006_+006_OBJ");
    printf("解压缩成功");

    JlCompress::compressDir("c:\\data\\obj\\test55.zip","C:\\data\\obj\\Tile_+006_+006_OBJ");
    printf("压缩成功");

    a.quit();


    return a.exec();
}

本blog地址:https://blog.csdn.net/hsg77

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值