Qt用QuaZip实现压缩/解压的小Demo

来源:互联网 发布:视频直播软件开发 编辑:程序博客网 时间:2024/06/05 04:24

效果图:


关键代码:

#include "squazip.h"#include "../quazip/JlCompress.h"#include <QtConcurrent/QtConcurrent>SQuaZip::SQuaZip(QObject *parent) : QObject(parent){}void SQuaZip::saveAsFile(const QString &path, const QString &zipfile){    QtConcurrent::run(this, &SQuaZip::zipDir, path, zipfile);}void SQuaZip::loadFromFile(const QString &path, const QString &zipfile){    QtConcurrent::run(this, &SQuaZip::unzipDir, zipfile, path);}/** * @brief SQuaZip::zipDir * @param path 待压缩目录 * @param zipfile 压缩后的文件 * @return */bool SQuaZip::zipDir(const QString &path, const QString &zipfile){    bool bok = JlCompress::compressDir(zipfile, path, true);    return bok;}/** * @brief SQuaZip::unzipDir * @param zipfile 待解压缩的文件 * @param path 解压缩存放的目录 * @return */bool SQuaZip::unzipDir(const QString &zipfile, const QString &path){    bool bok = !JlCompress::extractDir(zipfile, path).isEmpty();    qDebug() << "??::" << bok;    return bok;}

更多详细代码请直接联系本人。

原创粉丝点击