Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

& lt;Qt frameless window to achieve drag and zoom

Shulou Source: shulou.com Published: 2022-06-03 07:44:01 11月23日 Update

How to make the window without border blabla not to write?

/ /. Cpp

Void Dialog::mousePressEvent (QMouseEvent * event) {px=event- > x (); py=event- > y (); / / record the relative window coordinates of the mouse pxx=geometry (). Width (); / / window width pyy=geometry (). Height (); / / window height hx=geometry () .x (); hy=geometry () .y () / / record the window properties when the mouse is pressed, the coordinates of the top left point of the window (hx,hy) kx=cursor (). Pos (). X (); ky=cursor (). Pos (). Y (); / / record the global coordinates of the mouse (there are probably other ways to record the mouse, but I can't QwQ update ();} void Dialog::mouseMoveEvent (QMouseEvent * event) {if (px > pxx-10&&pxsetGeometry (hx,hy,pxx+event- > x ()-px,pyy)) } if (py > pyy-10&&pysetGeometry (hx,hy,pxx,pyy+event- > y ()-py);} if (py > pyy-10&&pypxx-10&&pxsetGeometry (hx,hy,pxx+event- > x ()-px,pyy+event- > y ()-py);} if (px > 0&&px0&&pysetGeometry (hx+cursor (). Pos (). X ()-kx,hy+cursor (). Pos (). Y ()-ky,pxx,pyy) } / / for lengthening and widening, it should be possible to use both relative window coordinates and relative screen coordinates, but drag-and-drop operations can only calculate update () with relative screen coordinates;}

Anyway, it is to record the coordinates of the mouse click to the drag and zoom trigger area (the zoom area set here is apart from the rightmost and lowest part of the window, and the drag area is except the zoom area), and then record the coordinates when the mouse is clicked over and moved, and then add or subtract it. _ .

Tags: Coordinates mouse area screen time part border global width that is properties methods horizontal point to vertical height move Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno MariaDB Shulou Technology Linux