[Development] How to have equivalent of functions over-riding in Qml
Martin Leutelt
martin.leutelt at basyskom.com
Wed Jul 9 16:25:49 CEST 2014
Hi,
the problem is that your Derived.qml isn't actually derived from Base.qml, since you're using 'Item'instead of 'Base' as a root item. This will work:
Base.qmlItem { function method1() {}}
Derived.qmlBase { id: base}
SomeOtherQml.qml...Derived { id: derived1}...Calling derived1.method1() now will call the function in Base. If you add an identical function in Derivedwill then lead to function method1() of Derived being called.
Regards,Martin
travik <ravikiran.tallapalli at wipro.com> , 7/9/2014 3:45 PM:
Hi, I would like to have equivalent of compile time polymorphism in in
Qml. a.k.a function overriding.
I know inheritance can be obtained by including the base-class in derived
class. (A realisation of the principle called inheritance by composition)
I also want to have some default implementations of the baseclass to be
available and invoked, in case the derived class does not provide its own
implementation.
In Qml sense, a method is function. So
Base.qml
-----
Item
{
function method1()
{
}
}
Derived.qml (in same folder as base.qml)
------
Item
{
Base
{
id: base
}
}
SomeOtherQml.qml
---
..
Derived { id: derived1 ... }
.. else where in this file,
derived1.method1() - should call, Base::method1, because derived1 does
not re-implement it (in the sense of inheritance)
_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140709/79786fb4/attachment.html>
More information about the Development
mailing list