[Development] Serialising UI state in QML via QSettings and JSON: QByteArray vs QString
Mitch Curtis
mitch.curtis at qt.io
Tue Oct 30 15:04:02 CET 2018
> -----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/qqmlbu
> >
> 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.
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
More information about the Development
mailing list