Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-107443

qmlint: QQuickRectangle property shadowed

    XMLWordPrintable

Details

    • All

    Description

      The error message can be generated with this code:

      Rectangle {
          id: markerRect
          width: 40
          height: 40
          color: "red"
          opacity: 0.5
          border.width: 10
          border.color: "black"
          radius: 4
      
          // Cross
          Rectangle {
              width: 1
              height: markerRect.height - 2*(markerRect.border.width)
              anchors.centerIn: parent
              color: "black"
          }
          Rectangle {
              width: markerRect.width - 2*(markerRect.border.width)
              height: 1
              anchors.centerIn: parent
              color: "black"
          }
      
          // Marker number
          Label {
              color: "white"
              anchors.left: markerRect.left
              anchors.top: markerRect.top
              anchors.leftMargin: markerRect.border.width
              anchors.topMargin: markerRect.border.width
              text: "Text"
          }
      }
      
      Error: main.qml:193:54: Could not compile binding for topMargin: Member width of QQuickPen of QQuickRectangle::border with type QQuickPen can be shadowed
                      anchors.topMargin: markerRect.border.width
      

      Maybe it's a missing "FINAL" in the property definition as described here: https://www.qt.io/blog/compiling-qml-to-c-avoiding-duck-typing?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qtqmlteam Qt Qml Team User
            Harald Meyer Harald Meyer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes