Signal handler onAnchorsChanged is throwing error.
-
When the following code is ran, qml is throwing loading error.
import QtQuick 2.6 import QtQuick.Window 2.2 import QtQuick.Controls 1.0 Window { visible: true width: 640 height: 480 title: qsTr("App1") Item { id: panel anchors.verticalCenter: parent.verticalCenter visible: true width: 100 onAnchorsChanged: console.log("anchors changed") } }
i am seeing error message as : qrc:/main.qml:17 Cannot assign to non-existent property "onAnchorsChanged" .
What is causing the error? i was just curious whether this has any special use case or not.Thanks in advance.
-
@Nitheesh
anchors
is a grouped property which never changes, thus it has no notify signal and also no corresponding slot.
Only the properties of the anchors object change.So you rather need to do
anchors.onCerticalCenterChanged: { ... }
-
@raven-worx Thank u. Could you please explain why the anchors doesn't change? Does this mean that other properties for eg: onWidthChanged changes ?
-
As @raven-worx already told, anchors is grouped property. It just a wrapper to group related properties. What changes here is the property which is inside the grouped property. e.g anchors.top, anchors.bottom etc will change you need to handle property change of these. anchors.onTopChange().. anchors.onBottomChanged()..
-
@Nitheesh If the issue is resolved, move the issue to SOLVED state.