Use Qdebug to print pointer addresses under QT

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.