How to Center a Window on the Screen

From Qt Wiki
Revision as of 12:14, 28 June 2015 by Wieland (talk | contribs) (Wieland moved page Center a Window on the Screen to How to Center a Window on the Screen: underscores)
Jump to navigation Jump to search
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

English | Deutsch | Български | 한국어

How to center a window on the screen

#include <QStyle>
#include <QDesktopWidget>

window->setGeometry(
 QStyle::alignedRect(
 Qt::LeftToRight,
 Qt::AlignCenter,
 window->size(),
 qApp->desktop()->availableGeometry()
 ));