Results 1 to 6 of 6

Thread: how to detect window resize event ?

  1. #1
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default how to detect window resize event ?

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to detect window resize event ?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to detect window resize event ?

    ok, thanks. Dziekuje

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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to detect window resize event ?

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to detect window resize event ?

    Quote Originally Posted by wysota View Post
    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.

  6. #6
    Join Date
    Apr 2011
    Location
    Russia
    Posts
    85
    Thanks
    2
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to detect window resize event ?

    Qt Code:
    1. QTimer resizeTimer;
    2.  
    3. resizeTimer.setSingleShot( true );
    4. connect( &resizeTimer, SIGNAL(timeout()), SLOT(resizeDone()) );
    5.  
    6. void MainWindow::resizeEvent( QResizeEvent *e )
    7. {
    8. resizeTimer.start( 500 );
    9. QMainWindow::resizeEvent(e);
    10. }
    11.  
    12. void MainWindow::resizeDone()
    13. {
    14. // Something doing
    15. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Jonny174 for this useful post:

    phenoboy (2nd October 2013)

Similar Threads

  1. Detect click event in QPlainTextEdit
    By qt_developer in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2013, 15:10
  2. Detect shift/cntrl/alt without event
    By tuli in forum Qt Programming
    Replies: 1
    Last Post: 3rd May 2013, 16:21
  3. Detect screen rotation or resize
    By leoalvesmachado in forum Newbie
    Replies: 2
    Last Post: 9th April 2010, 01:20
  4. resize event
    By wirasto in forum Qt Programming
    Replies: 6
    Last Post: 16th July 2009, 10:01
  5. Resize event
    By boss_bhat in forum Qt Programming
    Replies: 5
    Last Post: 19th July 2006, 15:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.