Qt: Simple Example for Quazip

前端 未结 2 1461
星月不相逢
星月不相逢 2021-02-15 16:19

I built the quazip library. I need a simple example that shows how to unzip a zip File. For example.

Quazip zipFile( QFile(\"test.zip\") );
zipFile.unzip();
         


        
2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-15 16:58

    Here is a quick example showing how to read the files. You will need to make some modifications to the code in the loop to write the data to a file or perform whatever operations your application requires:

    QuaZip zip("zipFile.zip");
    zip.open(QuaZip::mdUnzip);
    
    QuaZipFile file(&zip);
    
    for(bool f=zip.goToFirstFile(); f; f=zip.goToNextFile()) {
        file.open(QIODevice::ReadOnly);
        //same functionality as QIODevice::readData() -- data is a char*, maxSize is qint64
        file.readData(data,maxSize);
        //do something with the data
        file.close();
    }
    
    zip.close();
    

提交回复
热议问题