Hi all,
Firstly being new on this forum, i quickly present myself. My Name is John, i'm 25 and i'm a french student to an IT engineering school.
I'm currently trying to develop a simple QT C++ 11 program to compress all files contained into a directory.
I want to use qCompress from QByteArray class to do this trick.
I got to do it in a single threaded environment, so now i want to compress in a multi threaded environment by using QtConcurrent.
But i have no idea on how to do it properly.
Here a draft i written :
QFile outFile
("testCompress.ecf");
foreach
(const QString &file,future.
results()){ //Fichier d'entrée
nonCompressedData.append(inFile.readAll());
inFile.close();
text += file + "\n";
}
//QByteArray compressedData(qCompress(nonCompressedData,9));
//PROBLEM HERE
QFuture<QByteArray> futureCompressor = QtConcurrent::filtered(nonCompressedData,qCompress);
futureCompressor.waitForFinished();
QByteArray compressedData
= futureCompressor.
results();
outFile.write(compressedData);
QFile outFile("testCompress.ecf");
outFile.open(QIODevice::WriteOnly);
QByteArray nonCompressedData;
foreach(const QString &file,future.results()){
//Fichier d'entrée
QFile inFile(file);
inFile.open(QIODevice::ReadOnly);
nonCompressedData.append(inFile.readAll());
inFile.close();
text += file + "\n";
}
//QByteArray compressedData(qCompress(nonCompressedData,9));
//PROBLEM HERE
QFuture<QByteArray> futureCompressor = QtConcurrent::filtered(nonCompressedData,qCompress);
futureCompressor.waitForFinished();
QByteArray compressedData = futureCompressor.results();
outFile.write(compressedData);
To copy to clipboard, switch view to plain text mode
But i have some compilation errors.
I think it is a bad way to do this so i need some help to go on the right way.
Compilations errors :
First : No matching function for call to filtered(&QByteArray,).
Second : converstion from QList to non scalar type QByteArray requested.
Thanks in advance
Bookmarks