QByteArray to QString

前端 未结 7 767
野性不改
野性不改 2020-12-13 18:13

I\'m having issues with QByteArray and QString.

I\'m reading a file and stores its information in a QByteArray. The file is in

7条回答
  •  无人及你
    2020-12-13 18:46

    you can use QString::fromAscii()

    QByteArray data = entity->getData();
    QString s_data = QString::fromAscii(data.data());
    

    with data() returning a char*

    for QT5, you should use fromCString() instead, as fromAscii() is deprecated, see https://bugreports.qt-project.org/browse/QTBUG-21872 https://bugreports.qt.io/browse/QTBUG-21872

提交回复
热议问题