"PyQt5" (03) The Gospel of obsessive-compulsive disorder: Display the form in the center of the screen

Source: Internet
Author: User

Special Instructions

In order to directly show the focus of this article, the past period content will no longer be written into the code, the reader can encode their own combination on demand

In order to better display the effect, the code snippet will be in the form of pictures, if you want to copy the code can move to the author's GitHub

in order to facilitate learning, each article only solves a small problem, If you have questions, please refer to the previous content or leave a comment in the comments section

Environment description

Platform: WIN10 (Education edition)

Environment: Anaconda5.2 (Python3.6.6)

ide:pacharm2018.2.2 (Professional Edition)

pyqt5:5.11.2

Mission objectives

Set the position and size of the form

Place the form in the center of the screen

Output: An empty form is displayed in the center of the screen

Branch explanation

5: qdesktopwidget in the qtwidgets module class provides information about the desktop window, such as the screen size

18: Get a rectangle of the same size as the form

19: Get the center point of the screen

20: Let the center of the rectangle move to the center point of the screen

21: Move the upper-left corner of the form to the upper-left corner of the rectangle

Finish

Previous post: Changing the position and size of a form

Next article: Set the form title

"PyQt5" (03) The Gospel of obsessive-compulsive disorder: Display the form in the center of the screen

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.