Results 1 to 7 of 7

Thread: How to temporarily stop draw updates?

  1. #1
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to temporarily stop draw updates?

    I have a widget that sets itself up in setupUi(). However, when it sets up, it performs all sorts of drawing in the dialog before it is finally done (resizes itself, adds items, etc), which is quite ugly. Is there a way to halt drawing temporarily, so that the app doesn't go through all this intermediary drawing - so when I re-enable drawing, it looks as if it was drawn cleanly in one step?

    I tried to do hide() and show() before and after the setupUi(), but it still has to flicker as it hides and then gets redrawn with show(). Is there a better way?
    Software Engineer



  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 temporarily stop draw updates?

    Qt Code:
    1. setUpdatesEnabled(false);
    2. bigVisualChanges();
    3. setUpdatesEnabled(true);
    To copy to clipboard, switch view to plain text mode 

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

    gfunk (14th June 2006)

  4. #3
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to temporarily stop draw updates?

    Thanks! Seems to always be something in Qt that does what you want.
    The setUpdatesEnabled(false) seems to have gotten rid of perhaps 95% of the flicker; I am still getting tiny bit left though, and I've traced it to inside of setupUi():

    vboxLayout->addWidget(treeView);

    Not sure how to deal with this one though; I tried explicitly doing setUpdatesEnabled(false) on the treeView, and it did nothing (probably because child widgets are affected by the flag anyway). and vboxLayout being not a widget, so I couldn't call the function on it. What I ended up trying for this was calling setVisible(false) on the parent widget, and that seems to do the trick. Kind of hacky though...
    Software Engineer



  5. #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 temporarily stop draw updates?

    Quote Originally Posted by gfunk
    Thanks! Seems to always be something in Qt that does what you want.
    Maybe not always, but most of the times

    The setUpdatesEnabled(false) seems to have gotten rid of perhaps 95% of the flicker; I am still getting tiny bit left though, and I've traced it to inside of setupUi():

    vboxLayout->addWidget(treeView);

    Not sure how to deal with this one though; I tried explicitly doing setUpdatesEnabled(false) on the treeView, and it did nothing (probably because child widgets are affected by the flag anyway). and vboxLayout being not a widget, so I couldn't call the function on it. What I ended up trying for this was calling setVisible(false) on the parent widget, and that seems to do the trick. Kind of hacky though...
    Do you have anything unusual in the tree view? What causes the flicker?

  6. #5
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to temporarily stop draw updates?

    Nothing special about the treeView, just a regular QTreeWidget. There are a couple other widgets added to this vboxLayout as well, I'm not sure why they don't trigger the flicker. I will probably have to step through some more code to try to find what other differences it has.
    Software Engineer



  7. #6
    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 temporarily stop draw updates?

    But do you add those widgets when the parent is visible?

  8. #7
    Join Date
    Apr 2006
    Location
    San Francisco, CA
    Posts
    186
    Thanks
    55
    Thanked 12 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to temporarily stop draw updates?

    Yes, the flicker during the addWidget() call would occur while the parent was visible. Is that a no-no? I guess I assumed that a setupUi call would implicitly disable draw updates until it was completely done with setup. So, maybe calling setVisible isn't such a hack after all...
    Last edited by gfunk; 14th June 2006 at 20:39.
    Software Engineer



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.