Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Serializacion con QDataStream

    Spanish
    2
    2
    240
    Loading More Posts
    • 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.
    • A
      Albert Huert last edited by

      Hola,
      como puedo hacer la serializacion de un QString?
      He ejecutado el código ejemplo que hay en la clase QDataStream, pero no me realiza la serialización del QString, solo del entero, la salida en el archivo es la siguiente: the answer*
      Y el código es el siguiente:
      QFile file("/Users/eduardo/My Cloud/Programas/readFileLineToLine12/dat1.txt");
      if (!file.open(QIODevice::WriteOnly/* | QIODevice::Append*/)) {
      QMessageBox::information(this, tr("Unable to open file"), file.errorString());
      return;
      }
      QDataStream out(&file);
      out.setVersion(QDataStream::Qt_5_4);
      out << QString("the answer is");
      out << (qint32)42;
      file.flush();
      file.close();

      Muchas gracias

      1 Reply Last reply Reply Quote 0
      • VRonin
        VRonin last edited by

        42 en ASCII es *. usas QTextStream en lugar de QDataStream

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply Reply Quote 2
        • First post
          Last post