Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.15.0
-
None
-
GCC 7.5
Description
Porting my application to Qt 5.15.0 causes a runtime warning when using QML Connections, stating:
Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>)\{ ... }
After making the suggested change it works fine for most properties, except for `enabled`, a built-in property, which causes the following error:
Duplicate method name: invalid override of property change signal or superclass signal
Hereby an example of the warning, the error, and the workaround I use for now.
Example code of the warning:
import QtQuick 2.15 import QtQuick.Window 2.15 Window { visible: true width: 640 height: 480 title: qsTr("This file causes a warning") Item { id: item enabled: true } Connections { target: item onEnabledChanged: console.log("whatever") } } // This file causes a warning: // // qrc:/main.qml:15:5: QML Connections: Implicitly defined onFoo properties in Connections are deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }
Example code of the error after fixing the warning in the suggested way:
import QtQuick 2.15 import QtQuick.Window 2.15 Window { visible: true width: 640 height: 480 title: qsTr("This file causes an error") Item { id: item enabled: true } Connections { target: item function onEnabledChanged() { console.log("whatever") } } } // This file causes a runtime error: // // QQmlApplicationEngine failed to load component // qrc:/main.qml:17:18: Duplicate method name: invalid override of property change signal or superclass signal
Example code of workaround:
import QtQuick 2.15 import QtQuick.Window 2.15 Window { visible: true width: 640 height: 480 title: qsTr("This file works fine") Item { id: item enabled: true // property alias enabled2: enabled // Causes an error: qrc:/main-workaround.qml:13:34: Invalid alias reference. Unable to find id "enabled" property bool enabled2: enabled // works fine } Connections { target: item function onEnabled2Changed() { console.log("whatever") } } }