I want to maintain compatibility between any other applications on the planet (including web applications) when compressing text. Since qCompress and qUncompress seem to go against the grain, I am trying to use zlib directly from my Qt application.
I will accept the simplest (most minimal) answer that shows me how to use the zlib library with QByteArray directly OR change the output of qCompress so that it can be used outside of the Qt application.
Here is my uncomfortable attempt:
QByteArray tdata = QString("Oh noes!").toUtf8(); QByteArray cdata; uLongf len = 12 + 1.002*tdata.length(); compress(&cdata, &len, &tdata, tdata.length());
And the error:
error: cannot convert 'QByteArray *' to 'Bytef *' for argument '1' for 'int compress (Bytef *, uLongf *, const Bytef *, uLong)'
Then I tried using QByteArray :: constData ()
compress(cdata.constData(), &len, &tdata, tdata.length());
But the following error turned out:
Error: Incorrect conversion from 'const char *' to 'Bytef *'
I have no idea what Bytef is, so I'm starting to search the zlib sources for research. But all I can find is in QtSources / src / 3rdparty / zlib / zconf.h
# define Bytef z_Bytef
So now I'm just lost.
user336063
source share