Den 10-05-2012 16:39, Jeremy skrev:
> 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?

You can something like it by placing them in two files. Content of 
Monster.qml:

Item {
   property int attack: 3
   property int defend: 2
}

Content of SpecificMonster.qml:

Monster {
   attack: 4 ...
}

Bo Thorsen,
Fionia Software.

-- 

Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to