QML objects inside JavaScript in QML
-
I tired to use QML anchoring function inside Javascript functions.But is doesn't work. It is for anchoring the item like rectangle with window so,it should resize according to the window dynamically.
function clearAnchors(item) { item.anchors.left = undefined; item.anchors.top = undefined; item.anchors.right = undefined; item.anchors.bottom = undefined; item.anchors.horizontalCenter = undefined; item.anchors.verticalCenter = undefined; item.anchors.fill = undefined; item.anchors.centerIn = undefined; item.anchors.right = parent.right; item.anchors.bottom = parent.bottom; // ... repeat for other anchors if needed }
when assignining to parent.bottom/parent.right,error hits saying like QQuickAnchorsLine not assigned with number
-
I tired to use QML anchoring function inside Javascript functions.But is doesn't work. It is for anchoring the item like rectangle with window so,it should resize according to the window dynamically.
function clearAnchors(item) { item.anchors.left = undefined; item.anchors.top = undefined; item.anchors.right = undefined; item.anchors.bottom = undefined; item.anchors.horizontalCenter = undefined; item.anchors.verticalCenter = undefined; item.anchors.fill = undefined; item.anchors.centerIn = undefined; item.anchors.right = parent.right; item.anchors.bottom = parent.bottom; // ... repeat for other anchors if needed }
when assignining to parent.bottom/parent.right,error hits saying like QQuickAnchorsLine not assigned with number
@Vijaykarthikeyan
parent.right
isn't defined in this context. Tryitem.parent.right
instead.But just doing
item.anchors.fill = item.parent
should be enough. -
@Vijaykarthikeyan
parent.right
isn't defined in this context. Tryitem.parent.right
instead.But just doing
item.anchors.fill = item.parent
should be enough.@GrecKo Thank you..it works
-
@Vijaykarthikeyan
parent.right
isn't defined in this context. Tryitem.parent.right
instead.But just doing
item.anchors.fill = item.parent
should be enough.This post is deleted! -