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. Overwriting the existing property with alias
Qt 6.11 is out! See what's new in the release blog

Overwriting the existing property with alias

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 889 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.
  • Q Offline
    Q Offline
    QtYury
    wrote on last edited by
    #1

    I got this code from http://qt-project.org/doc/qt-5/qtqml-syntax-objectattributes.html#considerations-for-property-aliases (I made small modifications)
    @
    import QtQuick 2.2

    Rectangle {
    width: 360
    height: 360

    Rectangle {
        id: coloredrectangle
        width: 100
        height: 100
        border { color: black; width: 1 }
        property alias color: bluerectangle.color
        color: "red"
    
        Rectangle {
            id: bluerectangle
            color: "blue"
        }
    }
    

    }
    @

    The resulting rectangle is white. Why? I was expecting it to be blue.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Moderators Qt Champions 2024 Qt Champions 2022 Qt Champions 2017
      wrote on last edited by
      #2

      alias 'colour' actually refers to the blue rectangle colour. colorrectangle should be 'red'. It will not change to blue as it is just a alias. It should have been set to red internally. Since it is not setting to 'red', I feel it is bug.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      https://www.pthinks.com

      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