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
Forum Updated to NodeBB v4.3 + New Features

Overwriting the existing property with alias

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 605 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
      Qt Champions 2022
      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
      http://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