Using Qdebug to print the pointer address under QT is a great way to use it.
Qdebug () <<"parent--1"<<this->parent ();
The output is:
The output of the pointer precisely explains the physical address of the pointer (pending), and the type of the pointer.
//----------------------------------------------
The problems that I encountered,
I put a widget in a parent widget,
And added a qscrollarea to the parent widget, and put the widget inside the Qscrollarea.
I need to use the function under the parent widget in a function of the child widget.
You need to use the this->parent pointer to get a pointer to the parent class.
But through the method of printing pointers above, it is found that the Qscrollarea pointer is obtained.
I know that Qscrollarea's parent is my father's widget, so I get the real parent widget with this->parent ()->parent ().
People can use this method to solve their own problems according to their own situation.
Use Qdebug to print pointer addresses under QT