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

qmlsc: enum, property, method mixup for QLocale

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.6
    • 6.5.0 RC
    • QML: Compiler
    • None

    Description

      The following code

      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Component.onCompleted: {
              const l = Qt.locale()
              console.log(l, typeof l, l.monthName)
          }
      
          Text {
              text: Qt.locale().monthName(5, Locale.LongFormat)
          }
      }
      

      produces

      Warning: Main.qml:12:36: Member "monthName" not found on type "QLocale" [missing-property]
              console.log(l, typeof l, l.monthName)
                                         ^^^^^^^^^
      Warning: Main.qml:12:36: Could not compile binding for onCompleted: Cannot load property monthName from QLocale of QLocale. [compiler]
              console.log(l, typeof l, l.monthName)
                                         ^^^^^^^^^
      Warning: Main.qml:16:27: Type is an enum. You cannot access "monthName" from here. [restricted-type]
              text: Qt.locale().monthName(5, Locale.LongFormat)
                                ^^^^^^^^^
      Warning: Main.qml:16:27: Could not compile binding for text: Type QLocale of QLocale does not have a property monthName for calling [compiler]
              text: Qt.locale().monthName(5, Locale.LongFormat)
                                ^^^^^^^^^
      

      which are misleading.

      Attachments

        Activity

          People

            qtqmlteam Qt Qml Team User
            cajus Cajus Pollmeier
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: