Results 1 to 5 of 5

Thread: Is there a way to find when resize is done??

  1. #1
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Is there a way to find when resize is done??

    Hi,

    Is there any signal or a way to check when resize is complete for QWidget?
    Actually I want to stop the drawing on my map control when it is being resized and then start it again once the resize is complete.

    Regards,
    Raj

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: Is there a way to find when resize is done??

    Is there any signal or a way to check when resize is complete for QWidget?
    Try reimplement QWidget::resizeEvent or using QObject::eventFilter.
    ~ We are nothing in this universe ~

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is there a way to find when resize is done??

    When do you consider the resize "complete"?

    You can do something like this, which stops the widget's layout from updating until there has been no resize event for a configurable time:
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class LazyResizeWidget: public QWidget
    5. {
    6. Q_OBJECT
    7. public:
    8. LazyResizeWidget(QWidget *p = 0): QWidget(p)
    9. {
    10. m_timer = new QTimer(this);
    11. m_timer->setSingleShot(true);
    12. connect(m_timer, SIGNAL(timeout()), SLOT(resizeStopped()));
    13.  
    14. // Just for example content
    15. QFrame *f = new QFrame(this);
    16. f->setFrameStyle(QFrame::Plain | QFrame::Box);
    17. QVBoxLayout *l = new QVBoxLayout(this);
    18. l->addWidget(f);
    19. setLayout(l);
    20. }
    21.  
    22. protected:
    23. void resizeEvent(QResizeEvent *event)
    24. {
    25. QLayout *l = layout();
    26. if (l) {
    27. m_timer->start(StoppedTimeout);
    28. l->setEnabled(false);
    29. }
    30. QWidget::resizeEvent(event);
    31. }
    32.  
    33. private slots:
    34. void resizeStopped()
    35. {
    36. QLayout *l = layout();
    37. if (l) {
    38. l->setEnabled(true);
    39. l->update();
    40. }
    41. }
    42.  
    43. private:
    44. enum { StoppedTimeout = 500 };
    45. QTimer *m_timer;
    46. };
    47.  
    48.  
    49. int main(int argc, char**argv)
    50. {
    51. QApplication app(argc, argv);
    52. LazyResizeWidget w;
    53. w.resize(640, 480);
    54. w.show();
    55. return app.exec();
    56. }
    57.  
    58. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Nov 2009
    Posts
    129
    Thanks
    4
    Thanked 29 Times in 29 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Is there a way to find when resize is done??

    Quote Originally Posted by rajji_saini View Post
    Is there any signal or a way to check when resize is complete for QWidget?
    Actually I want to stop the drawing on my map control when it is being resized and then start it again once the resize is complete.
    Do you mean when the user is resizing the window (by dragging an edge or a corner)?

    If so, and if the target platform is Windows, what you need are the WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE messages. I don’t have a good opportunity to test right now, but if QWidget::winEvent gets those messages, you should be able to use them to do what you need.

  5. #5
    Join Date
    Aug 2010
    Posts
    36
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Is there a way to find when resize is done??

    Thanks Coises ...

Similar Threads

  1. Replies: 1
    Last Post: 28th May 2012, 15:06
  2. Replies: 3
    Last Post: 11th December 2011, 10:09
  3. Replies: 1
    Last Post: 9th May 2011, 20:45
  4. Replies: 1
    Last Post: 1st May 2010, 23:03
  5. Replies: 2
    Last Post: 22nd January 2008, 16:10

Tags for this Thread

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.