Solved QFile to QDevice error
-
Hi i get the follow error:
'QDataStream::QDataStream(const QDataStream &)' : el argumento 1 no puede convertirse de 'QFile **' a 'QIODevice *' Los tipos se¤alados no est n relacionados; la conversi¢n requiere reinterpret_cast, conversi¢n de estilo de C o conversi¢n de estilo de funci¢n
If i use a pointer i can read the file with qdatastream like:
QFile *archivoStub; archivoStub = new QFile(); archivoStub->setFileName(QApplication::applicationFilePath()); archivoStub->open(QFile::ReadOnly); /* Leer los datos de la trama*/ QDataStream in(&archivoStub); QString trama; qint32 a;
??
-
QFile *archivoStub; // ... QDataStream in(archivoStub); // <-- !
-
Hi
As wieland says so compact.
You are using take address operator "&" on a the QFile * pointer.
So it sees it as QFile ** ( pointer to pointer)
and it just want a pointer so it complains.
Hence the solution is to just give it the archivoStub without & as its already a pointer.Had you done
QFile archivoStub; // not pointer then
QDataStream in(&archivoStub); // take address of so it becomes *.