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

ListElement: Make enum assignments compilable by qmlsc

    XMLWordPrintable

Details

    Description

      Code

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          width: 640
          height: 480
          visible: true
      
          enum MyEnum {
              Alpha,
              Bravo,
              Charlie
          }
      
          ComboBox {
              textRole: "key"
              valueRole: "value"
              model: ListModel {
                  ListElement { key: "A"; value: Main.MyEnum.Alpha }
                  ListElement { key: "B"; value: Main.MyEnum.Bravo }
                  ListElement { key: "C"; value: Main.MyEnum.Charlie }
              }
              onActivated: console.log(currentIndex, currentText, currentValue)
          }
      }
      

       

      qmlsc output

      Warning: Main.qml:19:28: Could not compile binding for value: Cannot resolve property type  for binding on value. [compiler]
      Warning: Main.qml:20:28: Could not compile binding for value: Cannot resolve property type  for binding on value. [compiler]
      Warning: Main.qml:21:28: Could not compile binding for value: Cannot resolve property type  for binding on value. [compiler]
      

      Assigning string/numeric constants are fine, but assigning enums produces warnings. It doesn't matter whether the enums are defined in QML or C++.

      Attachments

        Issue Links

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

          Activity

            People

              qt.team.quick.subscriptions Qt Quick and Widgets Team
              skoh-qt Sze Howe Koh
              Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes