Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.7.2
-
None
-
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 |
570600,3 | qmllint: Avoid pointless warnings about JavaScript types | dev | qt/qtdeclarative | Status: MERGED | +2 | +1 |
570852,3 | qmllint: Avoid pointless warnings about JavaScript types | 6.8 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
571627,2 | qmllint: Avoid pointless warnings about JavaScript types | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |