Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QStringList to QByteArray??



  • Is there aby way how to pass QStringList to QByteArray? And then back, from QByteArray to QStringList?



  • What about serialization like?:

    QByteArray ba;
    QDataStream ds(&ba);
    ds << my_stringlist;

    QByteArray ba;
    QDataStream ds(&ba);
    ds >> my_stringlist;



  • May be.

    // edit: or:
    @
    QByteArray tmp;
    for(int i = 0; i < args.count(); i++) {
    tmp.append(args.at(i).toAscii());
    tmp.append(",");
    }
    @


  • Moderators

    Did you read the documentation? There are quite some ways to get a QByteArray from a QString and a QString from a QByteArray listed in the documentation of QString.

    Which one you want to use depends on which encoding you want/have in your QByteArray.



  • Tobias, he is asking not about conversion, but more about (de)serialization (QStringList <> QByteArray, not QString <> QByteArray) :) . Previous answers are quite full I think


Log in to reply