Solved 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
-
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
One
inTwo
andThree
makes a has-a relationship between them i.eTwo
andThree
contains (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
Two
extendsOne
which means it extends theRectangle
plus has its own properties as well and also contains new elementText
. If you runTwo.qml
you will see it will be ofwidth
andheight
200 but it will have its color "red" which it inherited fromOne.qml
. This meansTwo
inherited thecolor
property as well has have it own new properties. - Adding
-
This post is deleted! -
This post is deleted!