c++qtquazip

Zipping a .txt file in Qt


I have a simple application in Qt where the user enters data in a text file, which is then saved on desktop. After that I would like to be able to insert the .txt file in a .zip file.

I have tried to use QuaZIP with no success, it seems too complicated to understand.

Any help or suggestion would be greatly appreciated.


Solution

  • Bugless archive library is pretty good.This is how you would add files to an archive.

    bool addFilesToArchive(const QString& archiveName, const QStringList& fileNames, const QString& password )
    {
        Archive a;
        a.setArchiveName( archiveName );
    
        if ( !password.isEmpty() )
        {
            a.setPassword( password );
        }
    
        return a.addFiles( fileNames );
    }
    

    For more checkout the library at http://www.bugless.co.uk/products/archive/archive.html