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();
    /* Leer los datos de la trama*/
    QDataStream in(&archivoStub);
    QString trama;
    qint32 a;


  • QFile *archivoStub;
    // ...
    QDataStream in(archivoStub); // <-- !

  • Qt Champions 2017

    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 *.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.