qt 5.15.2压缩和解压缩功能

qt 5.15.2压缩和解压缩功能

主要是添加qt项目文件.pro内容:

这里要先下载quazip的c++项目先编译后引入到本项目中/zip目录下

cpp 复制代码
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内容如下所示:

cpp 复制代码
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

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

相关推荐
猷咪6 小时前
C++基础
开发语言·c++
IT·小灰灰6 小时前
30行PHP,利用硅基流动API,网页客服瞬间上线
开发语言·人工智能·aigc·php
快点好好学习吧6 小时前
phpize 依赖 php-config 获取 PHP 信息的庖丁解牛
android·开发语言·php
秦老师Q6 小时前
php入门教程(超详细,一篇就够了!!!)
开发语言·mysql·php·db
烟锁池塘柳06 小时前
解决Google Scholar “We‘re sorry... but your computer or network may be sending automated queries.”的问题
开发语言
是誰萆微了承諾6 小时前
php 对接deepseek
android·开发语言·php
2601_949868366 小时前
Flutter for OpenHarmony 电子合同签署App实战 - 已签合同实现
java·开发语言·flutter
打工的小王6 小时前
redis(四)搭建哨兵模式:一主二从三哨兵
数据库·redis·缓存
星火开发设计6 小时前
类型别名 typedef:让复杂类型更简洁
开发语言·c++·学习·算法·函数·知识
qq_177767376 小时前
React Native鸿蒙跨平台数据使用监控应用技术,通过setInterval每5秒更新一次数据使用情况和套餐使用情况,模拟了真实应用中的数据监控场景
开发语言·前端·javascript·react native·react.js·ecmascript·harmonyos