⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geometry.html

📁 qtopiaphone英文帮助,用于初学者和开发人员,初学者可以用来学习,开发人员可以用来资料查询.
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Qt Toolkit -  Window Geometry</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }--></style></head><body bgcolor="#ffffff"><p><table width="100%"><tr><td><a href="index.html"><img width="100" height="100" src="qtlogo.png"alt="Home" border="0"><img width="100"height="100" src="face.png" alt="Home" border="0"></a><td valign="top"><div align="right"><img src="dochead.png" width="472" height="27"><br><a href="classes.html"><b>Classes</b></a>- <a href="annotated.html">Annotated</a>- <a href="hierarchy.html">Tree</a>- <a href="functions.html">Functions</a>- <a href="index.html">Home</a>- <a href="topicals.html"><b>Structure</b>  <font face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular" align="center" size=32>Qte</font></a></div></table><h1 align="center"> Window Geometry</h1><br clear="all"><h2> Overview</h2><p>QWidget provides several functions that deal with a widget'sgeometry.  Some of these functions operate on the pure client area(i.e. the window excluding the window frame), others include thewindow frame. The differentiation is done in a way that covers themost common usage transparently.<p><dl>  <dt><strong>Including the window frame:</strong>  <dd>x(), y(), frameGeometry(), pos() and move()  <dt><strong>Excluding the window frame:</strong>  <dd> geometry(), width(), height(), rect() and size()</dl><p>Note that the distinction only matters for decorated top-levelwidgets. For all child widgets, the frame geometry is equal to thewidget's client geometry.<p>This image shows most of the functions in use:<center><img src="geometry.png" alt="Illustrating image"></center><p><h2> Unix/X11 peculiarities </h2><p>On Unix/X11, a window does not have a frame until the window managerdecorates it. This happens asynchronously at some point in time aftercalling show() and the first paint event the window receives - or itdoes not happen at all. Keep in mind that X11 is policy-free (otherscall it flexible). Thus you cannot make any safe assumption about thedecoration frame your window will get. Basic rule: There's always oneuser who uses a window manager that breaks your assumption, and whowill complain to you.<p>Furthermore, a toolkit cannot simply place windows on the screen. AllQt can do is to send certain hints to the window manager. The windowmanager, a separate process, may either obey, ignore or misunderstandthem. Due to the partially unclear Inter-Client CommunicationConventions Manual (ICCCM), window placement is handled quitedifferently in existing window managers.<p>X11 provides no standard or easy way to get the frame geometry oncethe window got decorated. Qt solves this problem with nifty heuristicsand clever code that works on a wide range of window managers thatexist today. Don't be surprised if you find one where frameGeometry()returns bogus results, though.<p>X11 also does not provide a way to maximize a window. TheshowMaximized() function in Qt therefore has to emulate thefeature. Its result depends totally on the result of frameGeometry()and the capability of the window manager to do proper windowplacement, both of which cannot be guaranteed.<p><h2>Restoring a Window's Geometry</h2><p>A common task in modern applications is to restore a window's geometryin a later session. On Windows, this is basically storing the resultof geometry() and calling setGeometry() in the next session beforedoing show(). On X11, this won't work because an invisible windowdoesn't have a frame yet. The window manager would decorate the windowlater. When this happens, the window shifts towards the bottom/rightcorner of the screen depending on the size of the decoration frame. Xtheoretically provides a way to avoid this shift. Our tests haveshown, though, that almost all window managers fail to implement thisfeature.<p> A workaround is to call setGeometry() after show(). This has the two disadvantages that the widget appears at a wrong place for a millisecond (results in flashing) and that currently only every second window manager gets it right. A safer solution is to store both pos() and size() and to restore the geometry using resize() and move() before calling show(), as demonstrated in the following example:<p><pre>        MyWidget* widget = new MyWidget        ...        <a href="qpoint.html">QPoint</a> p = widget-&gt;pos();       // store position        <a href="qsize.html">QSize</a> s = widget-&gt;size();       // store size        ...        widget = new MyWidget;        widget-&gt;resize( s );    // restore size        widget-&gt;move( p );      // restore position        widget-&gt;show();         // show widget</pre><p>This method works on both MS-Windows and most existing X11 windowmanagers.<p><address><hr><div align="center"><table width="100%" cellspacing="0" border="0"><tr><td>Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -