[Interest] QML property vs. id.property

Alexander Dyagilev alervdvcw at gmail.com
Sat Oct 5 20:03:27 CEST 2024


Hello,

I'm getting different results if I use object's id or not when accessing
its property.

Let's look at this code example:

Window {
    id: root

    property var x

    Text {
        visible: x
        text: "test"
    }
}

Text is invisible, as it should be. But if I replace "visible: x" with
"visible: root.x" when Text becomes visible and I'm getting the following
error in the Application's output pane: "Unable to assign [undefined] to
bool".

If I change "property var x" to "property var x: null" then I'm able to
access it using root.x with no issues.

What is happening here? Is this a bug or an expected behavior?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20241006/011bae35/attachment.htm>


More information about the Interest mailing list