Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Component Components Properties not-existing
Forum Updated to NodeBB v4.3 + New Features

QML Component Components Properties not-existing

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Itehnological
    wrote on last edited by
    #1

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

    Main.qml
    @ComplexButton {
    background.color: '#fff000'
    }@

    ComplexButton.qml
    @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?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      raaghuu
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        Itehnological
        wrote on last edited by
        #3

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

        UPDATED:

        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?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chriadam
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved