Qt World Summit: Register Today!

QML Component Components Properties not-existing

  • I am working on a simple UI with QML. Here is my issue:

    @ComplexButton {
    background.color: '#fff000'

    @Item {
    property alias background: background

    Image {
    property alias color: rect.color

    id: background

    Rectangle {
    id: rect

    And I get the following error:
    @Main.qml:2 - Cannot assign to non-existent property "color"@

    Which is kind of weird. The property color is inaccessible. I came across this "bug":https://bugreports.qt-project.org/browse/QTBUG-10082 where a similar issue is introduced but according to that it has been fixed. I am using the latest version of Qt SDK - downloaded about two weeks ago.

    Any idea?

  • Ok... i tried fooling around a bit with this code... the closest i got to an explanation was the error

    @untitled1.qml:5:5: Invalid property assignment: "background" is a read-only property@
    that's when i use the rect directly in the Item aliasing... so probably you can only access the properties, not modify them

  • Hi,
    After playing with it for some time I noticed the following:
    @ComplexButton {
    Component.onCompleted: {
    background.color = '#00fff'
    works perfectly, so I guess that by then the element isn't initialized yet.


    Also, if I change that color property to a string instead of alias like that:
    @property string color: '#00000000'@

    I got the same error. So the uninitialized element has to be the Image.
    How can I fix that?

  • This is a bug. I've filed QTBUG-26290 to track this issue.

Log in to reply