code for How to Compress a File In QT4???
code for How to Compress a File In QT4???
Could you give more details? Do you want to use a specific algorithm?
Suppose if i pass any file for Example file.txt it should compress and give me in file.zip ...
For that i need any code or Algorithm....
But do you want .zip specifically? Qt doesn't have zip support built in so you'd have to link with an additional library that performs zipping. But if you're interested in any kind of compression, Qt can do zlib (gzip) compression through qCompress().
I want to compress store in .zip format only .... I have used QCompress it is compressing but if i try to open that file.zip it's give me error ... and i can't be able to extract it...
I have used the following code
QFile inFile("map.txt");
inFile.Open(QIODevice::ReadOnly);
QByteArray ba=inFile.readAll();
QFile file("map.zip");
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
out<<qcompress(ba);
As I said qCompress doesn't use zip but gzip. For zip compression you have to use libzip or an external application like (pk)zip/winzip/whatever.
How to use libzip or external Application in my code .... Please let me know in detail...
I can highly recommend OSDaB zip
Your pro file should include the following.
The zlib functionality should already be linked in with the Qt library. Otherwise there is a usage example on the OSDaB page mentioned above.Qt Code:
# set includepath to 3rdparty so we will find <zlib/zlib.h> INCLUDEPATH += $(QTDIR)/src/3rdparty/ ... HEADERS += OSDaB/unzip.h SOURCES +=OSDaB/unzip.cppTo copy to clipboard, switch view to plain text mode
Hi,,
Thank you very much...
How do I decompress the zip file generated which doesn't have header information ?
Bookmarks