Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Spanish
  4. Serializacion con QDataStream
Forum Update on Monday, May 27th 2025

Serializacion con QDataStream

Scheduled Pinned Locked Moved Unsolved Spanish
2 Posts 2 Posters 403 Views
  • 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 Offline
    A Offline
    Albert Huert
    wrote on last edited by
    #1

    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
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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
      2

      • Login

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