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