Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
790 views
in Technique[技术] by (71.8m points)

qt - QML: List all object members/properties in console

Is there any way to list all object members/properties in QML & Qt 5.1?

Such as:

var obj=myQObject;
console.log(obj)
// expected output:
// obj { x:123..... }

This would be very helpful for debugging.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Straight javascript offers what you are looking for:

JSON.stringify(anything)

It works on QML items such as Rectangle, and it also works on most arbitrary objects!

Converting an object to a string


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...