Child form Actions

Source: Internet
Author: User

The parent window inherits the Qmainwindow class, creating a new child window in the class that inherits the Qdialog class

<span style= "White-space:pre" ></span>stepdialog* m_pstepdialog;<span style= "White-space:pre" > </span>m_pstepdialog = new Stepdialog (this);

The child window is then manipulated.

The child window displays full screen :

QT Widget Qwidget member function Showfullscreen () is used to display the widget in full screen, but he is only useful for widgets in windowed mode. The child window is characterized by a qt::subwindow, not a separate window. Therefore, the call to Showfullscreen () is not valid. By calling the child window: Setwindowflags (Qt::D ialog), or Setwindowflags (Qt::window), set it to windowed mode, you can call Showfullscreen () and display it in full screen.

If you want to revert to a normal window, call Setwindowflags (Qt::subwindow) To set the child window to a non-top-level window, and then call Shownormal () to display the Atomic window.

Reference :

Relative to the child window of the full-screen display method, you have to mention the child window exit full-screen method.

MFC, the child window to exit the full-screen method is straightforward, directly call the SetWindowPos () function to display the child window to a predetermined position.

In Qt, it is not effective to use move and resize to position the window directly. The child window needs to be set to a non-windowed mode first. Then move the window to the desired position.

That is, call Setwindowflags (Qt::D ialog), or Setwindowflags (Qt::subwindow), and call the move and resize functions.

When someone mentions exiting full screen, call Shownormal (), and then Setwindowflags (Qt::subwindow).

Here are two questions: 1) shownormal () is also valid only for top-level windows. 2) consider calling Shownormal () to set the window to its original size, and set the window to child window mode. However, the window returns to the parent window and does not show the original size.

child window transparent display:

This->setwindowopacity (0.7);//Set transparent 1-all transparent  
If not added
This->setwindowflags (Qt::D ialog | Qt::framelesswindowhint);
This sentence, the setting of transparency must be accompanied by a
to set a subform to a specified window:

One: Child window Creation Method:

A subform on a QT form is typically created by "new", and when the parent form is deleted, the associated subform is also cleaned up;

If the subform is not created by "new", but is created with a static variable, the program crashes when the parent form is closed because the parent form is not correct when it is deleted to the static subform;

Such as:

Main form functions:

void Slot_newwidget ()
{

This can cause problems;
Static NewQWidget1 nqwt (this);
nqwt.show ();


General Creation Method:
NewQWidget1 * PNewQWidget1 = new NewQWidget1 (this);
Pnewqwidget1->show ();

}



Two: The Sub-window setting method:

(1): Typically, for a subform that inherits from Qwidget, the direct new NewQWidget1 (this), the (or setparent (this)) parameter is set to the parent form, and then show () so that a child window can be created on the specified window;


(2): If a window inherits with Qdialog, in this way,

NewQWidget1 * PNewQWidget1 = new NewQWidget1 (this);
Pnewqwidget1->show ();

Just create a non-modal dialog box, if you want this modal dialog to appear on the specified window, workaround:

To set the properties of this window:

(1): Pnewqwidget1->setwindowflags (Qt::widget); Directly set Qdialog to Qwidget;

Pnewqwidget1->show (); Re-display after setting;

(2):

Pnewqwidget1->setwindowflags (Qt::subwindow); Set Qdialog as child window property;

Pnewqwidget1->show (); Re-display after setting;


(3):

Pnewqwidget1->setwindowflags (qt::customizewindowhint| Qt::framelesswindowhint);//Set custom borderless windows;

Pnewqwidget1->show (); Re-display after setting;


The above simple enumeration of three methods, but can be set according to specific needs;


Child form Actions

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.