Performance problem with QFile.
I'm trying to calculate the hash of some disk image files (.iso)
so i have to read the entire file and store it in QByteArray to pass it later to QCryptographicHash::Hash
the problem is with reading performance, it takes a lot of time and the system freeze while using QFile::readAll() and storing it in byte array.
is there any solution to reduce the time and prevent the system form freezing?
Use the stream operators. QCryptographicHash has an API that works with streaming QIODevices, too.
can you write a small piece of code :)
MuldeR last edited by
Try like this:
@/max bytes to read at once/
static const qint64 CHUNK_SIZE = 4096;
/process file contents/
QByteArray temp = file.read(CHUNK_SIZE);
temp = file.read(CHUNK_SIZE);
const QByteArray res = hash.result();
qDebug("Hash is: %s", res.toHex());@
thank you, now it works times better :)