Resize from within resizeEvent don't stick
-
Hi, I am calling resize() from within resizeEvent but when I release the mouse button when I'm done dragging the window reverts back to the original size it had before I started resizing.... anyone knows why and how to change that?
-
Hi,
Before going further in that direction, read the warning "here":http://qt-project.org/doc/qt-5/qwidget.html#size-prop
-
@void Widget::resizeEvent(QResizeEvent * event)
{
QSize size = event->size();
QSize oldSize = event->oldSize();int height = size.height(); int width = size.width(); int oldHeight = oldSize.height(); int oldWidth = oldSize.width(); if (height != oldHeight && width == oldWidth) { width = height; resize(width, height); } else if (width != oldWidth && height == oldHeight) { height = width; resize(width, height); }
}
@ -
try it.. the flickers seem to be caused by the fact that the underlying painting mechanism for top-level windows always go back painting the original size.. and when you release the mouse it reverts back again... what controls the painting of top-level widgets?!
-
It works in Gnome-flashback environment. It is gnome 3 with gnome 2 look.
There are some artifacts caused by calling resize from resizeEvent.I think you should consider the warning that SGaist pointed.
If you need to resize a window as a square then resizeEvent() is not good approach because it is called when resize is already done.
-
Well if it does work under different GUI manager then it's probably Windows window manager that is wacky... is there like a way to know on mouse click that the window resize border are being grabbed or something like that?
-
You may try to use "Event filters":http://qt-project.org/doc/qt-5/eventsandfilters.html#event-filters
But since Qt does not control titlebar, I think a frame around window is also not under Qt control, so it is possible that you will not get any events before resize is finished.
In this case you may try to implement frame and resize by yourself.
Something like in "this":http://qt-project.org/faq/answer/how_can_i_handle_events_in_the_titlebar_and_change_its_color_etc example. -
I have already tried filtering events. But the second option you pointed out seems to me like a really good idea I'll try this one out.