overriding a property fixed by an external component
I want to ovverride the height value for the image defined in a external PictureBox.qml file:
Code:
import QtQuick 2.0
FocusScope {
id: container
...
Column {
id: column
...
Image {
id: icon
width: parent.width; height: 150
...
this code is called in Main.qml in this way:
Code:
Component {
id: userDelegate
PictureBox {
???
...
how can I override height value for the Image element, without touching PictureBox.qml code?
Re: overriding a property fixed by an external component
You can´t access internal properties in the children of the components because of scope, the tool provided by QML to access internal properties are "property aliases", that way your PictureBox.qml must contain a single line in the root element with the structure: "property alias name: id.property"
Code:
import QtQuick 2.0
FocusScope {
id: container
propery alias iconHeight: icon.height //alias
...
Column {
id: column
...
Image {
id: icon
width: parent.width; height: 150
...
and your Main would access that property like this:
Code:
Component {
id: userDelegate
PictureBox {
iconHeight: 100
...