PDA

View Full Version : how to detect window resize event ?



phenoboy
14th June 2013, 08:20
Is there a way to detect when a window is resized by a user from _start_ of resizing (holding mouse button down) to the end of resize (releaseing mouse press). I'd like to do some things during resize.

wysota
14th June 2013, 08:23
If the window manager doesn't do non-opaque resizing then no. If it does, you'll be getting resizeEvent() calls in your widgets. Otherwise you'll get the event just once when resizing is complete.

phenoboy
14th June 2013, 08:38
ok, thanks. Dziekuje :)

I tried to capture mousepress event but it looks like it is not fired on window border (where the resize starts)

wysota
14th June 2013, 09:16
Window title bar is not part of the application and furthermore pressing the mouse on the title bar is not the only way to resize a window.

What is the goal that you wish to achieve?

phenoboy
16th June 2013, 15:53
Window title bar is not part of the application and furthermore pressing the mouse on the title bar is not the only way to resize a window.

What is the goal that you wish to achieve?

My goal is to disable executing some parts of code execution during resize. Or on the other hand I may want to draw something else on the screen during resize of window. "During resize" I mean time when user has mouse pressed down on window border and moving the window. I also would need to know when resize is finished - mousebutton is released. Currently QWidget::resize() event is fired wheneven mouse is moved even a little.

I am going to try this by finding out if resize event is called when mouse button is pressed. Then I can be quite certain windows is being resized. When mouse button is released then resizing is stopped.

Jonny174
17th June 2013, 05:04
QTimer resizeTimer;

resizeTimer.setSingleShot( true );
connect( &resizeTimer, SIGNAL(timeout()), SLOT(resizeDone()) );

void MainWindow::resizeEvent( QResizeEvent *e )
{
resizeTimer.start( 500 );
QMainWindow::resizeEvent(e);
}

void MainWindow::resizeDone()
{
// Something doing
}