How to Center a Window on the Screen

From Qt Wiki
Revision as of 08:56, 24 February 2015 by Maintenance script (talk | contribs)

Jump to: navigation, search


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

How to center a window on the screen

<br />#include &lt;QStyle&amp;gt;<br />#include &lt;QDesktopWidget&amp;gt;

window-&gt;setGeometry(<br /> QStyle::alignedRect(<br /> Qt::LeftToRight,<br /> Qt::AlignCenter,<br /> window-&gt;size(),<br /> qApp-&gt;desktop()-&gt;availableGeometry()<br /> ));<br />