[Development] Serialising UI state in QML via QSettings and JSON: QByteArray vs QString
Mitch Curtis
mitch.curtis at qt.io
Tue Oct 30 08:37:24 CET 2018
> -----Original Message-----
> From: Edward Welbourne
> Sent: Monday, 29 October 2018 7:31 PM
> To: Mitch Curtis <mitch.curtis at qt.io>
> Cc: Qt development mailing list <development at qt-project.org>
> Subject: Re: [Development] Serialising UI state in QML via QSettings and
> JSON: QByteArray vs QString
>
> Mitch Curtis (29 October 2018 17:42)
> > To solve #2, I first tried simply saving a QVariant containing a
> > QByteArray (the contents of which were QDataStream's output). This
> > didn't work because Qt's JSON implementation doesn't support
> > QByteArray; it only supports QString. That is, calling
> > QJsonObject::fromVariantMap(map) where "map" contains a QVariant
> > containing a QByteArray will result in the corresponding JSON value
> > being invalid/null.
>
> I'm not sure where JSON got involved in that
What do you mean? It's in the title of the email; it's a popular choice for storing data like this, so I want SplitView's serialisation to be compatible with it.
>but if you can manage to use
> CBOR instead, it's just as happy with QByteArray as with QString (and round-
> trips them to QByteArray, IIRC). For details, see
> qtbase/src/corelib/serialization/qcborstream.h
>
> I've also no idea how well it plays with QSettings; hopefully you know enough
> to work it out from the QCbor API ...
Thanks, I'll take a look.
> Eddy.
More information about the Development
mailing list