Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
#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库
posted on 2015-10-10 10:11 ccsdu2009 阅读(2639) 评论(0)  编辑 收藏 引用 所属分类: QT编程

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理