Results 1 to 3 of 3

Thread: Resize event on stretch?

  1. #1
    Join Date
    Apr 2008
    Posts
    17
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Resize event on stretch?

    Hi,

    The central widget of main window displays digital map image. On resize event map image needs to be repainted. Image generation consumes much time and cause unacceptable lags when main window or centarl widget is resizeing by stretching.

    How to prevent resize events caused be stetching and fire one resize event when stretching is finished?

    Thanks a lot!

  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: Resize event on stretch?

    You can't - your operating system controls that. But you can react to resize events in a smart way. When you receive a resize event start a timer that will fire after say... 1 second. If you see another resize event before it timeouts - restart the timer so that you have another second. Now for the best part - the timer should also set a flag that the widget is being resized and the timeout slot should reset that flag (and call update() on the widget). Then, in your paint event check if the flag is set. If it is - you know are during a resize. In that case don't regenerate the complex drawing, instead draw something simple like "please wait" text.

    The outcome will be that your widget will be repainted one second after the resize is complete.

  3. The following user says thank you to wysota for this useful post:

    kodiak (29th August 2008)

  4. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Resize event on stretch?

    Thanks, Wysota. I have the same problem, and thought about using a timer as you suggest. I couldn't figure out the right logic to make it work well. I'll implement your approach.

Similar Threads

  1. Qt event queue overloading?
    By gct in forum Qt Programming
    Replies: 3
    Last Post: 17th March 2008, 18:39
  2. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  3. Resize event
    By boss_bhat in forum Qt Programming
    Replies: 5
    Last Post: 19th July 2006, 15:43
  4. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55
  5. postponing resize event
    By Honestmath in forum Qt Programming
    Replies: 11
    Last Post: 26th February 2006, 00:32

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.