[Interest] Pointers as Q_PPOPERTY

Дмитрий Козлов gnitry at mail.ru
Wed Oct 2 17:02:54 CEST 2013


02.10.2013 18:12, Николай Шатохин пишет:
> Hello
>
> I registered as QML Type class Ship inherited from QObject that have 
> fields:
>
> Q_PROPERTY(Hull hull READ hull)
> Q_PROPERTY(Reactor reactor READ reactor)
> Q_PROPERTY(Shields shields READ shields)
>
> (all field classes inherited from QObject too)
>
> But in ship class I'm using this fields as pointers (Hull * hull). So, 
> how to use correctly Q_Properties in this case? (I need call methods 
> from this fields and catch signals from them in QML)
>
> Can I use something like this Q_PROPERTY(Hull hull READ hull)?
> And then in QML:
>
> Ship
> {
>     id: ship
> Hull
>     {
>  id: hull_indicator
>  backend: ship.hull
>     }
>
> onDamage:
>     {
> ship.hull.reduce(damage);
>     }
> }
>
> Best regards,
> Nick
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
Maybe you looking for this (work with pointers) ?

Q_PROPERTY(Hull * hull READ hull)
Q_PROPERTY(Reactor * reactor READ reactor)
Q_PROPERTY(Shields * shields READ shields)

This approach should work in your case.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20131002/e99fba24/attachment.html>


More information about the Interest mailing list