K
K
Kalombyr2018-10-05 12:55:01
Qt
Kalombyr, 2018-10-05 12:55:01

Is it possible to add item properties to QML that will be inherited nested (of type Layout.*)?

Good day!
In general, subject.
I want it like this:
MyItem.qml

Item {
   property Ext: { color: "black"; }
}

main.qml
MyItem {
   Rectangle {
      Ext.color: "silver"
   }
   Rectangle {
      Ext.color: "gold"
   }
}

I found in the documentation how to do this from C ++ by creating my own component.
But I can’t find it from pure QML or I’m not looking there at all.
Tell me, please, is it possible and how?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kastuś, 2018-10-06
@Gytim

I don’t understand what is needed
either here
doc.qt.io/qt-5/qtqml-syntax-directoryimports.html
or
Image {
property bool checkable: true
source: "myFoto.img"
MouseArea {
anchors.fill: parent
onClicked: if(checkable === true) myFunction()
}
}

main.qml

import "/"
...
ImageButton {
id: selectAllButton
width: 50
height: 50
checkable: true
function myFunction() {
...
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question