[Interest] QML defining an object property

Jérôme Godbout godboutj at amotus.ca
Mon May 31 21:00:05 CEST 2021


This should be working (at least into 5.15.x). Binding value into the object should emit the changed normally.

Take care if you want a binding to react to values changed inside the dictionary/object inside you property, you will need to emit the change on the property.

Normally an easy way is to copy the value and modify it and reassign it. But here since you are readonly you cannot do that.

Try to emit changed when a dependencies is modified or when you set the value inside it.

Ex:
Function myEditFct()
{
    mainTbImg[‘up’] = “popo”;
    mainTbImgChanged(); // this is the missing piece often forgotten
}

Here an example that display the behavior
https://tinyurl.com/yg7ykwc4



From: Interest <interest-bounces at qt-project.org> on behalf of Alexander Dyagilev <alervdvcw at gmail.com>
Date: Monday, May 31, 2021 at 1:57 PM
To: interest at qt-project.org <interest at qt-project.org>
Subject: [Interest] QML defining an object property

Hello,

Am I right that this is not possible in QML?

readonly property var mainTbImg: {

        up: "some string",

        up_check: "some another string"

    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210531/0376f3b5/attachment.html>


More information about the Interest mailing list