Unsolved How to resize and snap frameless windows when drag to edges
-
Hi, Im created a frameless windows with qt widget (im using this flags and Attribute to make it framless
Qt::FramelessWindowHint
andQt::WA_TranslucentBackground
)
I want to know its possible to snap windows against other window and resize it when dragged to the edge of the screen like when we use normal window frame?
I read aboutstartSystemMove
andstartSystemResize
in document, but im not sure how can i use it in qt widget -
Hi
On win 10, it seems not to trigger if the window has no real titlebar -
even if we drag it otherwise.It is possible with native api.
https://forum.qt.io/topic/95542/enable-windows-autosize-function-on-frameless-qwidget/4 -
@mrjj thank you, I check it and yes looks like its working
but sadly I dont have any Idea about how to use it on existing project (ui file created with qt designer) do you have any tips about it? thanks -
@saeid0034
Hi
It wraps the actual widget so, on windows, you can use
qwinwidget.cppat line 128 where it says
//Create the true app widget
You can then instantiate your own widget and add to its layout. (m_Layout) -
@mrjj sorry for late respond
seems like its not usable in qt visual studio (qt6 visual studio 2019)
framless window is ok but window is not draggable (its working in qt creator though)
you have any Idea about it? -
@saeid0034
Hi
Sorry , i haven't tried it with Qt6. -
@mrjj In GitHub someone already fixed it
https://github.com/dfct/TrueFramelessWindow/pull/19
now window are resizable but still not draggable
I think its because in original code they use QToolBar for draggable part of window, but I used a label...
it should be ok but I dont know why its wont work -
my second problem was because of this code in nativeEvent
if (p_Widget->toolBar) { //If the mouse is over top of the toolbar area BUT is actually positioned over a child widget of the toolbar, //Then we don't want to enable dragging. This allows for buttons in the toolbar, eg, a Maximize button, to keep the mouse interaction if (QApplication::widgetAt(QCursor::pos()) != p_Widget->toolBar) return false; }
by removing it now window are draggable, but this time it only work sometime (i mean I need to click on label multiple time to be able to drag it)
-
after some searching I finaly found this and its working perfect
but still it have some minor problem like Minimize animation and Maximize animation dont show up (I don't know what is problem)