How to position dynamic created qml obj?
-
wrote on 18 Oct 2016, 11:46 last edited by
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
-
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
? :) -
wrote on 18 Oct 2016, 12:27 last edited by A Former User
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
wrote on 19 Oct 2016, 01:22 last edited by@Wieland
Oh,Thanks.
But,why this not work:
var obj = compoment.createObject(window, {color: "pink", "anchors.centerIn":parent}) -
@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
.
3/5