This code works, but I wonder if there is any simpler way:
def center(self):
qr = self.frameGeometry()
cp = gui.QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
just add this line to your main windows :
self.move(QtGui.QApplication.desktop().screen().rect().center()- self.rect().center())
self.move(QDesktopWidget().availableGeometry().center() - self.frameGeometry().center())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With