Skip to content

庄朋龙的博客

有志者自有千方万计,无志者只感千难万难。

Menu
  • 首页
  • 生活
  • 创业
  • 编程
  • 运维
  • 视频课程
    • 跨境独立站
    • Shopee跨境电商
    • TEMU跨境电商
  • 资源分享
    • 网站推荐
    • 开源推荐
    • 可商用字体
    • 书籍分享
Menu

Qt读zip文件

Posted on 2015年11月2日2025年3月4日 by 庄朋龙
#include <QtCore/QCoreApplication>
#include <QTextStream>
#include <QXmlStreamReader>
#include <QtXML/QDom.h>
#include <QZip/QuaZipFile.h>
#include <iostream>

int main(int argc,char *argv[])
{
    QCoreApplication app(argc,argv);
    QuaZip zip(":qrc/zip.zip");
    if(!zip.open(QuaZip::mdUnzip))
    {
        std::cout<<"open failed:"<<zip.getZipError()<<std::endl;
        system("pause");
        return -1;
    }

    if(zip.setCurrentFile("list.xml"))
    {
        QuaZipFile zipfile(&zip);
        if(!zipfile.open(QIODevice::ReadOnly))
        {
            std::cout<<"open zipfile failed"<<std::endl;
            system("pause");
            return -1;
        }

        QTextStream stream(&zipfile);
        while(!stream.atEnd())
            std::cout<<qPrintable(stream.readLine())<<std::endl;

        zipfile.close();
        zip.close();
    }
    else
        std::cout<<"set current file failed."<<std::endl;
    system("pause");
    return 1;
}

需要使用QuaZip库

Category: 编程, 资源分享

全栈开发者×创业偏执狂

相信代码能改变命运,也相信凌晨四点的服务器警报里有真实的人生。

我的创业项目:
SHOPAGG / SmallShop / DigitShops / 文硕阁

© 2025 庄朋龙的博客