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

[Reg 6.5 -> 6.7] Anonymous function on a signal results in QML Linter error when compiler warnings are enabled

    XMLWordPrintable

Details

    • 41d4612f6 (dev), 0c217ff0f (6.8), e66ffdd90 (6.7)

    Description

      Using an anonymous function on a signal results in the following QML Compiler error when compiler warnings are enabled for the QML linter:

      Warning: [..]/test/Main.qml: Object type function is not derived from QObject or QQmlComponent. You may need to fully qualify all names in C++ so that moc can see them. You may also need to add qt_extract_metatypes(<target containing >). [compiler]

      The error shows under Compile Output in Qt Creator when the QML linter is configured to show compiler errors, like so:

      CompilerWarnings=warning.

      No warnings appear under Issues in Qt Creator when this issue occurs.

      The following examples trigger the error.

      Example 1:

          MouseArea {
              anchors.fill: parent
              onEntered: () => {
                  console.log("Entered")
              }
          }
      

      Example 2:

          TextEdit {
              anchors.fill: parent
              onEditingFinished: () => {
                  console.log("Finished")
              }
          }
      

      Using the older anonymous JS function syntax also triggers the error:

      Example 1b:

          MouseArea {
              anchors.fill: parent
              onEntered: function() {
                  console.log("Entered")
              }
          }
      

      Example 2b:

          TextEdit {
              anchors.fill: parent
              onEditingFinished: () {
                  console.log("Finished")
              }
          }
      

       

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            javier.cordero Javier Cordero
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes