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.rightisn't defined in this context. Tryitem.parent.rightinstead.But just doing
item.anchors.fill = item.parentshould be enough. -
@Vijaykarthikeyan
parent.rightisn't defined in this context. Tryitem.parent.rightinstead.But just doing
item.anchors.fill = item.parentshould be enough.@GrecKo Thank you..it works
-
@Vijaykarthikeyan
parent.rightisn't defined in this context. Tryitem.parent.rightinstead.But just doing
item.anchors.fill = item.parentshould be enough.This post is deleted! -
V Vijaykarthikeyan has marked this topic as solved on