[Interest] qml 'subclasses'

Jeremy jswigart at gmail.com
Thu May 10 16:39:04 CEST 2012


I'm relatively new to QML so I'm not sure how to accomplish this.

Basically I want to define a custom object in QML, with custom properties
and functionality, and then I want to be able to 'subclass' that component
with different date for those standardized properties and whatever else
needs tailored to the instance.

To use a game analogy

Monster{

    id: npc

    property int attack: 3

    property int defend: 2

}


SpecificMonster {

    // would like to inherit from monster so that it shares functionality and

    // properties that are not overridden

    id: npc1

    property int attack: 4

    property int defend: 4

}


I could create a separate file/database of the instances, and
instantiate the monster component and fill in their properties with
setProperty, but I would like to keep everything in QML, in case a
specific subclass needs to provide more interactive functionality,
animation, or whatever else QML can provide.


Is there any way to do this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120510/9ab43a72/attachment.html>


More information about the Interest mailing list