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

Knoll Lars Lars.Knoll at theqtcompany.com
Mon Nov 9 10:10:56 CET 2015

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 

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.


More information about the Development mailing list