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

Using ListView attached properties inside and outside of delegates triggers vattached-property-reuse warning

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.8
    • 6.7.2
    • QML: Tooling
    • None
    • All

    Description

      Accessing a ListView attached property from inside a ListView's delegate while a ListView attached property is used within the ListView but outside of the delegate, and the linter's configuration (.qmllint.ini) has AttachedPropertyReuse=warning, results in an attached-property-reuse warning from QML linter.

      The following code triggers the warning:

          ListView {
              anchors.fill: parent
              model: 1
              orientation: ListView.Horizontal
              delegate: Rectangle {
                  width: 200
                  height: ListView.delayRemove ? 20 : 40
                  color: ListView.isCurrentItem ? "red" : "blue"
              }
          }
      

      The following code doesn't trigger the warning:

          ListView {
              anchors.fill: parent
              model: 1
              orientation: Qt.Horizontal
              delegate: Rectangle {
                  width: 200
                  height: ListView.delayRemove ? 20 : 40
                  color: ListView.isCurrentItem ? "red" : "blue"
              }
          }
      

      By setting orientation to use a Qt enumerator, the attached-property-reuse warning isn't triggered. The warning appears to come from the attached property being accessed from different scopes (in and outside the delegate).

      I suspect this might be intended behavior, but if this were the case then I would recommend updating ListView's documentation to suggest using Qt namespace enumerators where applicable instead of ListView's to prevent the warning.

      Attachments

        For Gerrit Dashboard: QTBUG-126527
        # Subject Branch Project Status CR V

        Activity

          People

            fabiankosmale Fabian Kosmale
            javier.cordero Javier Cordero
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change