[Interest] QML defining an object property

Pierre-Yves Siret py.siret at gmail.com
Tue Jun 1 09:52:12 CEST 2021


Le lun. 31 mai 2021 à 19:59, Alexander Dyagilev <alervdvcw at gmail.com> a
écrit :

> Hello,
>
> Am I right that this is not possible in QML?
>
> readonly property var mainTbImg: {
>     up: "some string",
>      up_check: "some another string"
> }
>

The problem is that QML doesn't know how to parse it,  it can't know if
it's a JS statement or a JS object definition. To disambiguate it you can
either write:

    readonly property var mainTbImg: ({
        up: "some string",
        up_check: "some another string"
    })

or :

    readonly property var mainTbImg: {
        "up": "some string",
        "up_check": "some another string"
    }

Encompass the declaration with parenthesis or the property names with
double quotes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210601/d215e517/attachment.html>


More information about the Interest mailing list