Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFile to QDevice error
Qt 6.11 is out! See what's new in the release blog

QFile to QDevice error

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 569 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by A Former User
    #1

    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;
    

    ??

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2
      QFile *archivoStub;
      // ...
      QDataStream in(archivoStub); // <-- !
      
      1 Reply Last reply
      6
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved