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

Konstantin Ritt ritt.ks at gmail.com
Sat Nov 7 23:45:59 CET 2015

Maybe JSON.stringify(obj) is what you need?


2015-11-07 21:52 GMT+04:00 Luke Parry <pumpkinteapot at gmail.com>:

> Is it possible to override the toString method for native c++ QObject
> types for use in QML scripts?
> e.g. using
> Q_INVOKABLE QString toString() const;
> This doesn't appear to work because it is overridden by some default
> implementation which returns a pointer value. Is this done intentionally?
> Could a workaround  be done through javascript prototype methods...
> It would just improve the readability of debug messages and errors when
> running scripts.
> Huge Thanks,
> Luke Parry
> _______________________________________________
> 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/20151108/1403cb66/attachment.html>

More information about the Development mailing list