Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Qt and zlib.
Skalli last edited by
What can I say, I've stumbled about something that is puzzling me.
I'm pretty new to Qt and I'm experimenting with the functions Qt has. In one of those experiments I wanted to load a zip file from the hard disk. A zip file is pretty useless if it's still zipped. Therefore I wanted to unzip the file. I knew Qt has these nice QCompress() and QUncompress() functions, yet I wanted to achieve my objective with zlib.
Using zlib in my Qt project was easy, the project compiled and run perfectly. Then I stumbled about something: When I printed out the version number of zlib, the result was 1.2.3. Wasn't I using 1.2.5? Indeed, I did!
My first thought was that there might be older version of the DLL in my system files, but there wasn't. Yet the project ran. Even without the zlib1.dll in the executive path. I realised that the project compiled in release mode to. And even linked, but I haven't set the linker settings for zlib in release mode. So I created another small C++ project where I used zlib and printed the version number. Nothing else. It said 1.2.5. It didn't run without zlib1.dll in the executive path or didn't link without the reference to zlib.dll. ;)
I can't remove the zlib header file from my project, otherwise the project won't compile. Now, how can this be? Is there a wrapper around zlib in Qt, and are the functions available in a global scope? Or how comes that everything works fine with just the zlib header file in my project?
Also, has someone an idea how I can achieve the goal of opening password protected zip files? I want to store sensitive files in a password protected zip file, so users can't change them without the programms supervision. Any libs, best practices or hints to achieve that? It hasn't to be a zip file, it also can be some kind of encrypted file.
Thanks in advance!
vsorokin last edited by
For work with ZIP look here: http://osdab.42cows.org/snippets/zip.php?mode=advanced
and here: http://quazip.sourceforge.net/
And more, Qt have undocumented classes QZipReader and QZipWriter.
tzander last edited by
Those classes are not only undocumented, they are also not exported so you won't be able to use them.
But indeed, Qt uses zip internally for things like writing compressed data into a pdf as well as compressing the XML that goes into an ODF document. So QtGui at least links to the libs and if your linker is not too picky it will just work with only a header file.
andre last edited by
If you want to use .zip files, you can also take a look at Bugless Archive. It works as a standard QIODevice, so you can use all normal Qt file IO functions on it. It is available under both a commercial and the GPL licence.
Smar last edited by
QuaZip is very lightweight(just few files that can be included to the source) and powerful for packaging, so I have been using it. IIRC it provides its own zlib headers, though, but then again, it will work anywhere.
Skalli last edited by
Thanks for the replies. :)
That's alot of useful information there. I will evaluate the libraries you recommended. :)
I ahve to say, Qt is a great framework. So powerful and easy to use. I hope there'll be a Plug-In for VS2010 soon.
iksaif last edited by
Here are some examples with quazip and libzip: "http://gitorious.org/serieswatcher/serieswatcher/blobs/master/src/updateworker.cpp":http://gitorious.org/serieswatcher/serieswatcher/blobs/master/src/updateworker.cpp
Check parseShowAndEpisodesZip function.
Yash last edited by
Excellent resource list.
Thank you guys