On Qt 5.15.1 I want to connect to the objectNameChanged signal of a QML Item using Connections:
import QtQuick 2.15
import QtQuick.Window 2.15
Window {
visible: true
Item {
id: foo
}
Connections {
target: foo
// onObjectNameChanged: console.log(foo.objectName) // old syntax, causes "Implicitly defined onFoo properties in Connections are deprecated."
function onObjectNameChanged() {
console.log(foo.objectName)
}
}
}
The code produces the following error:
Duplicate method name: invalid override of property change signal or superclass signal
I can of course write it like this:
Item {
id: foo
onObjectNameChanged: console.log(foo.objectName)
}
but I need to use Connections.
How to fix this?