QVector3D output in QString

I was surprised to learn that QVector3D does not have a built-in way to output the x, y, and z coordinates as a QString. I can write a simple function to do this, but I was wondering if there is a standard way to execute it?

+6
source share
1 answer

You can use QDebug::QDebug(QString*) , and the operator <<from QDebug:

 QString str; QDebug(&str) << QVector3D(1,2,3); 

But since this constructor is not declared explicitly, you can omit QDebug:

 QString str; &str << QVector3D(1,2,3); 

(I don't know if this is a bug or function, and if you can rely on this second form in future versions of Qt).

+8
source

Source: https://habr.com/ru/post/895350/


All Articles