c++ - How to correctly restore widgets that are resized by windows 7/vista aero snap -
Windows 7 has this functionality, where a window is pulled to the side of the screen, then it is maximized to take half of it.
. My problem is that I am trying to restore the size and position of the widget and when Windows 7 creates the "max" widget, QT still gives its status and size as if it is just now Also shown as normal , i.e. - completely incorrect position and size. Is there any control in QT5? I can not find it anywhere in the docs and its weird It is essentially what I do I am doing It seems that "framagemetry" part is necessary to compensate for widget boundaries. .pro is required for the file to work below.
QT + = gui-private
#include & lt; WinUser.h & gt; # Include & lt; Qpa / qplatformnativeinterface.h & gt; Fixed QWindow * windowForWidget (Constricted * Widget) {QWindow * window = widget- & gt; Windowhandle (); If (window) return window; Const QWidget * Basics = Widget-> NetworkWidget (); If (Native) Native Original- & gt; Window handle (); Return 0; } #include & lt; QWindow & gt; Static HWND getHWNDForWidget (Constant Cvdt * Widget) {QWindow * window = :: windowForWidget (widget); If (window and window-> handle ()) {compliant interfaces * natInterface = QGuiApplication :: platformNativeInterface (); Return Static_Cast & amp; Lt; Hwnd & gt; (Net Interface-> Native Resource Forward (QByteArrayLiteral ("Handle"), window); } Return 0; } Zero service (QWidget * w) zero {size; size; QPoint status; RECTPRact = {0}; Hwd hwd = getHWNDForWidget (w); GetWindowRect (hwnd, and pRect); Auto left = w-> gt; Frame gymetry () Left (); Auto correct = w-> gt; Frame gemetry (). right (); Auto width = w-> Width (); Pos.setX (pRect.left); Pos.setY (pRect.top); size.setWidth (pRect.right - pRect.left - (right - left - width)); Size.setHeight (pRect.bottom - pRect.top); // .... the rest of the code}
Comments
Post a Comment