Resize from within resizeEvent don't stick
-
wrote on 22 Jul 2014, 21:06 last edited by
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?
-
wrote on 22 Jul 2014, 21:22 last edited by
Could you show the source of your resizeEvent()?
-
Hi,
Before going further in that direction, read the warning "here":http://qt-project.org/doc/qt-5/qwidget.html#size-prop
-
wrote on 23 Jul 2014, 05:35 last edited by
@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); }
}
@ -
wrote on 23 Jul 2014, 05:37 last edited by
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?!
-
wrote on 23 Jul 2014, 19:40 last edited by
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.
-
wrote on 23 Jul 2014, 20:27 last edited by
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?
-
wrote on 24 Jul 2014, 15:33 last edited by
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. -
wrote on 24 Jul 2014, 20:29 last edited by
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.
1/9