[Development] Serialising UI state in QML via QSettings and JSON: QByteArray vs QString

Mitch Curtis mitch.curtis at qt.io
Tue Oct 30 15:05:27 CET 2018


> -----Original Message-----
> From: Development <development-bounces+mitch.curtis=qt.io at qt-
> project.org> On Behalf Of Mitch Curtis
> Sent: Tuesday, 30 October 2018 3:04 PM
> To: J-P Nurmi <jpnurmi at gmail.com>
> Cc: development at qt-project.org
> Subject: Re: [Development] Serialising UI state in QML via QSettings and
> JSON: QByteArray vs QString
> 
> > -----Original Message-----
> > From: J-P Nurmi <jpnurmi at gmail.com>
> > Sent: Tuesday, 30 October 2018 2:49 PM
> > To: Mitch Curtis <mitch.curtis at qt.io>
> > Cc: development at qt-project.org
> > Subject: Re: [Development] Serialising UI state in QML via QSettings
> > and
> > JSON: QByteArray vs QString
> >
> > On Mon, Oct 29, 2018 at 5:42 PM Mitch Curtis <mitch.curtis at qt.io> wrote:
> > > I thought that I could get around this by using Qt.atob() and
> > > Qt.btoa() in
> > QML to convert the byte array into a Base64 QString, but it turns out
> > that those functions expect a string:
> > >
> > > http://code.qt.io/cgit/qt/qtdeclarative.git/tree/src/qml/qml/v8/qqml
> > > bu
> > >
> >
> iltinfunctions.cpp?h=5.12&id=475c74a9926efcd968572563e678988e53804603#
> > > n996
> >
> > Hi Mitch,
> 
> Hey. :)
> 
> > So Qt.atob() and Qt.btoa() are not doing what they claim to do? Would
> > it be feasible to fix them?
> 
> 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.

Correcting myself here; the docs say "string":

"ASCII to binary - this function decodes the base64 encoded data string and returns it."

- http://doc.qt.io/qt-5/qml-qtqml-qt.html#atob-method

> 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.
> 
> 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.
> 
> What do you think about the proposed solution of saveState() returning a
> Base64 QString?
> 
> > --
> > J-P Nurmi
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list