I want to write the data to many different files randomly, So I store the QFile * to Qhash, But it seams not work. and there is a report
QObject::connect: No such signal QObject::aboutToClose() in ....\include\QtCore\5.3.2\QtCore/private/../../../../../src/corelib/io/qtextstream_p.h:75
Could you help me to solve this problem?
Here is a test code to realize my idea.
#include <QHash>
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QFile>
#include <QDebug>
int main(int argc, char *argv[])
{
QHash <qint32,QFile *> fileHandHash;
for(qint32 i=0; i<1000; i++){
qint32 id = i % 10;
qDebug() << i << "\t" << id;
if( ! fileHandHash.contains(id) ){
QString filename = id + ".out.txt";
QFile MYFILE(filename);
MYFILE.open(QIODevice::WriteOnly);
fileHandHash.insert(id,&MYFILE);
}
QTextStream OUT(fileHandHash.value(id));
OUT << i << "\n";
}
return 1;
}