QT window size, window size and size change caused by event qresizeevent.

Source: Internet
Author: User

Source: http://www.qtcn.org/bbs/apps.php?q=diary&a=detail&did=1277&uid=139581


Source: Http://blog.csdn.net/dbzhang800/article/details/6741344?reload
Operation:


Framegeometry ()


Geometric dimensions (position + size)


For Windows, including window decorators


X () y () POS ()


Contains location information only (upper-left coordinate)


Move ()


Move position only


Geometry ()


Geometric dimensions (position + size)


Window Adorner not included


Width () height () rect () size ()


Contains only size information


Setgeometry ()


Change position + size


Resize ()


Change size only



have been thinking about how to make the center window in the main window after the full screen, the center window is also scaled.
This includes, center window size adaptation, center window
1. Create your UI, which uses your top-level layout, check Widget window-right-click-Layout-Grid layout.

2. In the constructor

Copy code centralwidget = new Qwidget;
Qwidget * a = new Qwidget (centralwidget);
Ui1->setupui (a);
A->hide ();
Qwidget * b = new Qwidget (centralwidget);
Ui2->setupui (b);
B->hide ();
Setcentralwidget (Centralwidget)//The advantage is that you can make a lot of UI, you want to use which UI directly Uin->setupui (WIDGETN), and then Widgetn->show ().



3. However, if you want to drag the main window, you can make the window components can also be scaled with the window, you need to rewrite resizeevent, because after the construction, the size of the child window is fixed.

Copy code void Resizeevent (qresizeevent* size) {
Centralwidget->resize (Framegeometry (). Size ()); Whether to use size () or framegeometry.size () according to your own needs.
}



What is the problem, please leave a message to explain, we communicate and solve together.

Additional device-related screen size information, if you rewrite resizeevent words, I think this is unnecessary.
qdesktopwidget* desktopwidget = qapplication::d esktop ();
Get Customer Area Rectangle
Qrect clientrect = Desktopwidget->availablegeometry ();
Get the application Rectangle
Qrect applicationrect = Desktopwidget->screengeometry ();

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.