has a relationship in QML
-
hello
here is an example,
one.qml //filename
Rectangle
{} two.qml // filename one {}
three.qml // filename
one
{} is this has a re;ationship or inhertance?. -
inhertance
-
hello
here is an example,
one.qml //filename
Rectangle
{} two.qml // filename one {}
three.qml // filename
one
{} is this has a re;ationship or inhertance?.Hi @Pradeep-Kumar
Honestly I too had never thought of inheritance and relationship in QML but Ill try to explain.
Accroding to your code:- Adding
OneinTwoandThreemakes a has-a relationship between them i.eTwoandThreecontains (has i.e has a relationship)One. - I think there is no inheritance in between them.
Now in QML terms according to me inheritance would be something like this:
One.qmlRectangle { width: 50 height: 50 color: "red" }Two.qml
One { width: 200 height: 200 property string myProperty Text { anchors.centerIn: parent text: "Two" } }Now here
TwoextendsOnewhich means it extends theRectangleplus has its own properties as well and also contains new elementText. If you runTwo.qmlyou will see it will be ofwidthandheight200 but it will have its color "red" which it inherited fromOne.qml. This meansTwoinherited thecolorproperty as well has have it own new properties. - Adding