Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. One more time Debug operator<<
Qt 6.11 is out! See what's new in the release blog

One more time Debug operator<<

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 610 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    ofmrew
    wrote on last edited by
    #1

    I have placed```
    };
    QDebug operator<<(QDebug debug, const Matrix4x4 &m);
    #endif // MATRIX4X4_H

    outside 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?
    Christian EhrlicherC 1 Reply Last reply
    0
    • O ofmrew

      I have placed```
      };
      QDebug operator<<(QDebug debug, const Matrix4x4 &m);
      #endif // MATRIX4X4_H

      outside 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?
      Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • O Offline
        O Offline
        ofmrew
        wrote on last edited by
        #3

        Thanks, qDebug() << *T1; solved the problem, but honestly I believe that I tried that before--must of violated the cardinal rule of debugging: never make more than one change at a time. Again thanks.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved