- All (478)
- jom (0)
- Qt Linguist (7)
- Qt Eclipse Integration (9)
- Qt Designer (7)
- Qt Creator (4)
- Qt build system: qmake (31)
- Qt build system: configure (3)
- Qt Assistant (5)
- Printing (4)
- Porting from Qt 3 to Qt 4 (1)
- Plugins (7)
- Qt Visual Studio AddIn (2)
- Qt/MFC Migration (2)
- QtScript (3)
- MDI (2)
- XML (1)
- Widgets (22)
- WebKit (5)
- Tools and Containers (2)
- Threads (2)
- Text Handling (10)
- SQL (6)
- QtTest (1)
- QtService (1)
- Platform: Windows (49)
- Platform: Unix (16)
- Platform: Mac OS X (18)
- Image Formats (2)
- I/O (2)
- Graphicsview (8)
- Font handling (9)
- Event System (18)
- Drag and Drop (4)
- Dialogs (6)
- Desktop integration (3)
- ActiveQt (3)
- Itemviews (60)
- Layout (4)
- Qt Quick (10)
- Qt SDK (1)
- Licensing (2)
- Platform: Embedded Linux (38)
- Painting (32)
- OpenGL (4)
- Object Model (6)
- Network (5)
- Multimedia (3)
- Miscellanous (23)
- Main Window (19)
- Look and Feel (23)
- Development (0)
- Getting Involved (0)
- Routines (0)
How to compress data with Qt?
Qt uses the zlib library to provide compression. This means that you can compress and decompress your bytearrays of data using Qt. See the documentation on qUncompress() [qt.nokia.com]
Note that this does not produce file archives that can be opened by other applications, to do that you will need to write it yourself using Qt’s custom file handling system [qt.nokia.com] or use a 3rd party library.

5 comments
October 18, 2010
Mad Scientist
An IMHO useful 3rd party solution is the one by Bugless: http://www.bugless.co.uk/products/archive/archive.html
It works with Qt3 and Qt4, and has a dual GPL + commercial licence.
Also, Nokia itself provides a QtSolution called QtIOCompressor that may be useful: http://qt.nokia.com/products/appdev/add-on-products/catalog/4/Utilities/qtiocompressor/
The difference is that the solution by Bugless can work with complete archives (multiple files compressed into one file in standard WinZip format) while the solution only works on a single file. Both have their uses.
November 25, 2010
Lab Rat
kdelibs, from the KDE project, also has a QIODevice-subclass called KFilterDev, which can compress/uncompress data in gzip, bzip2 and xz formats, incrementally rather than all-in-one-go. It is relatively self contained in the directory http://websvn.kde.org/trunk/KDE/kdelibs/kdecore/compression/ and therefore easy to extract. And it’s LGPL licensed.
December 5, 2010
Ant Farmer
It’d be useful if there was an easy Qt compressor that supported encryption or code obfuscation too.
Read this topic for motive: http://developer.qt.nokia.com/forums/viewthread/2153/P15/
Basically, to hide QML files so people can’t simply rip yours and make a competing app.
December 5, 2010
Mad Scientist
Should be easy enough to achieve based on the tools mentioned above. You could simply XOR the data with some key. Or you use a crypto class, which is also available for Qt. Sure, you won’t get it 100% secure (ever, I think, since you are supplying the key as well as the data), but it is better than nothing.
December 19, 2010
Gene Splicer
http://quazip.sourceforge.net/ – Qt wrapper for zip/unzip