Simply move the window to center then show it. This can be done by calling QWidget::show() then QWidget::move(int, int) or QWidget::move(const QPoint&). You can access information about current desktop screen geometry from QApplication::desktop()->screenGeometry().
The implementation should be like this.
Qt Code:
int x = (screenGeometry.width()-mainWindow->width()) / 2; int y = (screenGeometry.height()-mainWindow->height()) / 2; mainWindow->move(x, y); mainWindow->show();To copy to clipboard, switch view to plain text mode




Reply With Quote
Bookmarks