[Development] Override toString() method for c++ QObject types in QML

Luke Parry pumpkinteapot at gmail.com
Tue Nov 10 12:12:08 CET 2015


That's fine. I was curious if this was possible or not in the current state
of QML2.

I do not yet have critical need for it but it could also be useful for
overriding the valueOf prototype. I will just use another method to provide
debug information about a QObject type.

Thanks for the quick answer,
Luke

On 9 November 2015 at 09:10, Knoll Lars <Lars.Knoll at theqtcompany.com> wrote:

>
> On 08/11/15 22:57, "Development on behalf of Stephen Kelly" <
> development-bounces at qt-project.org on behalf of steveire at gmail.com> wrote:
>
> >Konstantin Ritt wrote:
> >
> >> Maybe JSON.stringify(obj) is what you need?
> >>
> >
> >I think the intention is to override what that does using a specified
> >method.
>
> JSON.stringify() does something slightly different than what you can do by
> reimplementing toString().
>
> For toString(), the default implementation for the object prototype will
> currently get used. Implementing an invokable method on the wrapped QObject
> would be nice, but currently there is some logic in the engine missing that
> would allow that method to get picked up automatically.
>
> Cheers,
> Lars
>
>
> _______________________________________________
> 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/20151110/7cf253a2/attachment.html>


More information about the Development mailing list