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

Compiler may ignore dynamic Package properties

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • 6.x
    • 6.4.1
    • QML: Compiler

    Description

      Code like

      import QtQuick
      
      Window {
          id: win
          width: 640
          height: 480
          visible: true
          title: "Sandbox"
          property bool isMobile: false
      
          DelegateModel {
              id: myModel
              model: 5
              delegate: Package {
                  Item { Package.name: 'mobile' }
                  Item { Package.name: 'tablet' }
              }
          }
      
          Repeater {
              model: win.isMobile ? myModel.parts.mobile : myModel.parts.tablet
          }
      }
      

      results in

      Warning: main.qml:32:45: Property "mobile" not found on type "QObject"
              model: win.isMobile ? myModel.parts.mobile : myModel.parts.tablet
                                                  ^^^^^^
      Error: main.qml:32:45: Could not compile binding for model: Cannot load property mobile from QObject of QQmlDelegateModel::parts with type QObject.
              model: win.isMobile ? myModel.parts.mobile : myModel.parts.tablet
                                                  ^^^^^^

      .

      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
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes