How to Center a Window on the Screen: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Center a Window on the Screen Bulgarian|Български]] [[Center a Window on the Screen Korean|한국어]]
[[Category:snippets]]


=How to center a window on the screen=
'''English''' | [[Center_a_Window_on_the_Screen_German|Deutsch]] | [[Center_a_Window_on_the_Screen_Bulgarian|Български]] | [[Center_a_Window_on_the_Screen_Korean|한국어]]


Thanks to [http://developer.qt.nokia.com/member/5319 Peppe] ''[developer.qt.nokia.com]'' who pointed this out in this [http://developer.qt.nokia.com/forums/viewthread/3386/ forum thread] ''[developer.qt.nokia.com]''
= How to center a window on the screen =


===Categories:===
<code><br />#include &lt;QStyle&amp;gt;<br />#include &lt;QDesktopWidget&amp;gt;


* [[:Category:snippets|snippets]]
window-&gt;setGeometry(<br /> QStyle::alignedRect(<br /> Qt::LeftToRight,<br /> Qt::AlignCenter,<br /> window-&gt;size(),<br /> qApp-&gt;desktop()-&gt;availableGeometry()<br /> ));<br /></code>

Revision as of 08:56, 24 February 2015


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 />