In recent days, I am learning pyqt programming and using CSDN to record what I have learned, so as not to forget to laugh later
import sys From PyQt4 import qtgui import control module Class center (qtgui. QWidget): ා inherit the parent QWidget def __init__(self,parent=None): Qtgui. QWidget. Init (self, parent) requires two constructors, one for the center class and one for the QWidget class self.setWindowTitle('center') Self.resize (600300) - initialize form size self.center() Def Center (self): the window is in the center of the screen Screen = qtgui. Qdesktopwidget(). Screengeometry() ාqdesktopwidget is a class. Call the screengeometry function to get the screen size Size = self. Geometry() (ditto) Self.move ((screen. Width() - size. Width()) / 2, (screen. Height() - size. Height()) / 2) call move to move to the specified location app=QtGui.QApplication(sys.argv) qb=Center() qb.show() sys.exit(app.exec_())
The above example of how to display the window in the center of the screen in pyqt programming is all the content shared by Xiaobian. I hope it can give you a reference, and I hope you can support developpaer more.