Due to the different size of the computer, the fixed parameters of the window position set on one machine tend to perform poorly on the other machine.
Here's an example of moving a window to the center of the screen
1 ImportSYS2 fromPysideImportQtgui3 4 5 classPyside_center (qtgui.qwidget):6 7 def __init__(self):8Super (Pyside_center, self).__init__()9 Ten Self.initui () One A defInitui (self): - #Set Window Size -Self.resize (250, 150) the #call your own method of writing center - Self.center () - #Set Title -Self.setwindowtitle ('Center') + self.show () - + defCenter (self): A #get the data for the window, PySide.QtCore.QRect atQR =self.framegeometry () - #get the center point coordinates of a native visual window -CP =qtgui.qdesktopwidget (). Availablegeometry (). Center () - #move the Qrect to the center point - Qr.movecenter (CP) - #move the window itself to the center point using the position obtained by the simulated rectangle in Self.move (Qr.topleft ()) - to + - defMain (): the *App =qtgui.qapplication (SYS.ARGV) $ex =Pyside_center ()Panax Notoginseng Sys.exit (App.exec_ ()) - the + if __name__=='__main__': AMain ()
Pyside moving the window to the middle of the screen