One more time Debug operator<<
-
I have placed```
};
QDebug operator<<(QDebug debug, const Matrix4x4 &m);
#endif // MATRIX4X4_Houtside of the function declaration and have the implementation:
QDebug operator<<(QDebug debug, const Matrix4x4 &m){
QDebugStateSaver saver(debug);
debug.nospace() << "Row 1" << m.m11 << m.m12 << m.m13 << m.m14<<"\n"
<< "Row 2" << m.m21 << m.m22 << m.m23 << m.m24<<"\n"
<< "Row 3" << m.m31 << m.m32 << m.m33 << m.m34<<"\n"
<< "Row 4" << m.m41 << m.m42 << m.m43 << m.m44;
return debug;
}The Matrix4x4 I am trying to show is: "T1" 1 0 0 50 0 1 0 50 0 0 1 100 0 0 0 1 which is defined as Matrix4x4 * T1 = Matrix4x4().translate(50.0,50.0,100.0); and the debug attempt is qDebug() << T1; and the output is 0x20ea2bdcea0 I believe that I am following the Qt code shown in the woboq source code for QTransform. What is wrong?
-
@ofmrew said in One more time Debug operator<<:
Matrix4x4 * T1
qDebug() << T1;Because T1 is a pointer, you wrote an operator for an object. Pass an object to
operator <<
Apart from this I would see a need that a simply Matrix class is used via a pointer, esp. a translate() function should not return a pointer where you can forgot the delete it.