Issue
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())
Solution
No, it's the simplest way. Here is a snippet I've used in C++:
QRect desktopRect = QApplication::desktop()->availableGeometry(this);
QPoint center = desktopRect.center();
move(center.x() - width() * 0.5, center.y() - height());
Answered By - Dmitriy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.