Customization of component loaded with Loader.
-
wrote on 12 Oct 2020, 13:18 last edited by
Hello,
Is there a way to modify property of component loaded by Loader?simple example:
import QtQuick 2.7 import QtQuick.Controls 2.3 Rectangle { color: "#41cd52" anchors.fill: parent Component { id: comp Rectangle { width: 100 height: 100 color: "black" } } Loader { id: load sourceComponent: comp width: 200 //item.color: "red" // non existing property! How to change it? } }
-
Hello,
Is there a way to modify property of component loaded by Loader?simple example:
import QtQuick 2.7 import QtQuick.Controls 2.3 Rectangle { color: "#41cd52" anchors.fill: parent Component { id: comp Rectangle { width: 100 height: 100 color: "black" } } Loader { id: load sourceComponent: comp width: 200 //item.color: "red" // non existing property! How to change it? } }
-
wrote on 12 Oct 2020, 14:02 last edited by
Thank you!
Works great! :) -
Or declaratively and to have actual bindings:
Binding { target: loader.item property: "color" value: "red" }
-
wrote on 12 Oct 2020, 15:47 last edited by ODБOï 10 Dec 2020, 15:47
item.color = Qt.binding(function() { return "red" })
can work also
5/5