[Qt-qml] Calling a base item's overridden function?

Pelle Johnsen pelle.johnsen at gmail.com
Tue Mar 8 08:50:45 CET 2011


@Gregory: already tried using an id - doesn't work, it will call ItemB.foo
(causing an infinite loop in this case)

@aaron: Thanks for clarifying this. Would be great to have that supported in
future versions though, it's a pretty standard OO feature nowadays :)

I've worked around this by defining functions with separate names in the
base item, but it quickly gets tiresome in a larger hierarchy. Here is how
it can be done:

<ItemA.qml>

Item {
    funciton fooA() {
        console.log("fooA");
    }

    function foo() {
        fooA();
    }
}

<ItemB.qml>

ItemA {
    function fooB() {
        console.log("fooB");
        fooA();
    }

    function foo() {
        fooB();
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20110308/aac61b1f/attachment.html 


More information about the Qt-qml mailing list