Results 1 to 4 of 4

Thread: how to force an immediate repaint on a widget

  1. #1
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    54
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question how to force an immediate repaint on a widget

    On startup I do some synchronous processing and would like to update a QLabel object. The trouble is that since I don't go back to the event loop it won't redraw.

    I've tried calling "repaint" but it still doesn't force an immediate redraw (like the docs say it does).

    I've found that QCoreApplication::processEvents does the trick, but I'd prefer if I could somehow just redraw the one label widget.

  2. #2
    Join Date
    Sep 2010
    Posts
    145
    Thanks
    1
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to force an immediate repaint on a widget


  3. #3
    Join Date
    Aug 2010
    Location
    Germany
    Posts
    54
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to force an immediate repaint on a widget

    Thank you. I do a lot of that already once the program starts. I'm just stuck in the very specific case where I wish to do nothing but have one widget in particular redraw. This happens only during startup -- once started the app is totally asynchronous with all processing.

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to force an immediate repaint on a widget

    All GUI operations are done using an event loop, which means that your GUI thread should be responsive at ALL times, including startup. Commands such as repaint simply queue these requests in the message loop.

    If you have startup code that takes a long time to finish you should place this into a seperate thread, else you could find you are in an situation where the OS sends you a message, you do not reply and then the OS will freeze your window and display a message stating "This application is no longer responding.".

Similar Threads

  1. repaint widget
    By yxtx1984 in forum Newbie
    Replies: 4
    Last Post: 11th March 2010, 03:51
  2. Replies: 4
    Last Post: 3rd March 2008, 22:15
  3. Replies: 5
    Last Post: 18th April 2007, 10:29
  4. force repaint
    By georgie in forum Qt Programming
    Replies: 3
    Last Post: 22nd May 2006, 13:16
  5. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36

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.