"QT" controls the parent form in the subform

Source: Internet
Author: User

Tag: The control function shows the deletion of his by code

"Background notes" the name of my main form is called MainWindow, whose subwindow is a class called Subdialog. What I want to do now is call the parent window in the function of the child window.

Open a child window in the parent window

    // Popup dialog box to determine the parameters    of the transformation new Subdialog (this); // This place is very important    . Dialog->setmodal (true);    Dialog->show ();

In the above code, the parent window's pointer is passed to the child window through this, so you can use this passed pointer in a child window to control the parent window to do something.

Actions in the child window:

    MainWindow *ptr = (mainwindow*) parentwidget (); // This is a very important sentence to get a pointer to the parent form to use    Ptr->test (); // has successfully moved to the test function of the main dialog.    // Show parent Form    Delete  This // Delete itself

"QT" controls the parent form in the subform

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.