[Development] Serialising UI state in QML via QSettings and JSON: QByteArray vs QString
J-P Nurmi
jpnurmi at gmail.com
Tue Oct 30 15:52:13 CET 2018
On Tue, Oct 30, 2018 at 3:04 PM Mitch Curtis <mitch.curtis at qt.io> wrote:
> Their documentation doesn't claim that they operate on a specific type, so I'm not sure it's a matter of not doing what they claim to do.
They do promise to handle binary data, though. Representing binary
data with null-terminated strings makes them useless. The sole purpose
of base64 is to encode binary data to text that can be represented as
a string.
> Whether or not they could be extended to work with byte arrays is a question I don't have the answer to, though presumably it would involve modifying QV4::Value and who knows what else in the guts of QML.
The QML engine gained better QByteArray support recently (5.10?):
http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#qbytearray-to-javascript-arraybuffer
> Unfortunately it wouldn't help the use case I'm trying to support though, because there is still the problem of Qt's JSON implementation not supporting byte arrays.
Pass the state as a base64 string. Where does it turn to a byte array
if Qt.btoa() returns a string?
> What do you think about the proposed solution of saveState() returning a Base64 QString?
-1 :)
--
J-P Nurmi
More information about the Development
mailing list