How to position dynamic created qml obj?
Unsolved
QML and Qt Quick
-
I have such code
var compoment = Qt.createComponent("qrc:/ui/About.qml"); var obj = compoment.createObject(window,{"width": list.width, "height": list.height});
How to set anchors value for obj? Such anchors.fill: parent
@Mr-Pang
simply set it onobj
? :) -
Hi! Either like this:
var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":window.contentItem})
Or like that:
var obj = compoment.createObject(window, {color: "pink"}) obj.anchors.centerIn = window.contentItem
-
Hi! Either like this:
var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":window.contentItem})
Or like that:
var obj = compoment.createObject(window, {color: "pink"}) obj.anchors.centerIn = window.contentItem
-
@Wieland
Oh,Thanks.
But,why this not work:
var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent})@Mr-Pang said in How to position dynamic created qml obj?:
@Wieland
Oh,Thanks.
But,why this not work:
var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent})That too will work provided the
parent
is valid and found in that context or you can directly pass anid
of the item which it should be centered on instead ofparent
.