Results 1 to 6 of 6

Thread: how to force widgets update

  1. #1
    Join Date
    May 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default how to force widgets update

    Hi, the following code
    Qt Code:
    1. statusLabel = new QLabel(" idle ", this);
    2. statusBar()->addWidget(statusLabel);
    3.  
    4. statusLabel->setText("doing something");
    5. myobject->do_smth_for_minute();
    6. statusLabel->setText("something done");
    To copy to clipboard, switch view to plain text mode 
    does not update the statusLabel, it just stays "something done". How can I force updating the widget?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: how to force widgets update

    try calling update();
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 force widgets update

    You are blocking the event loop so the widget can't update itself. Read this article: [wiki]Keeping the GUI Responsive[/wiki].
    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.


  4. #4
    Join Date
    May 2010
    Posts
    23
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to force widgets update

    update() does not work (on windows at least). That is the point, I am afraid I need to put a task to a thread, but that just is not right, I do not need it to be responsive in between two updates of the widget, I only want to update it once before and once afterwards.

  5. #5
    Join Date
    Apr 2010
    Posts
    98
    Thanks
    19
    Thanked 8 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to force widgets update

    an easy way, set a QTimer which will timeout in a few millisec,connect its timeout SIGNAL
    It's not the goodbye that hurts,but the flashback that follow.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 force widgets update

    See the part of the article that deals with manually triggering event processing.

    @MorrisLiang: I'm afraid this won't work as event loop is blocked so timers don't fire. update() is called, it just doesn't cause the desired effect.
    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.


Similar Threads

  1. Replies: 1
    Last Post: 12th January 2010, 12:42
  2. Force geometry update of hidden widget
    By stburton in forum Qt Programming
    Replies: 7
    Last Post: 9th December 2009, 08:12
  3. Replies: 0
    Last Post: 7th August 2009, 16:10
  4. Widgets visual update / synchronization
    By Caius Aérobus in forum Qt Programming
    Replies: 4
    Last Post: 27th November 2007, 12:52
  5. Replies: 5
    Last Post: 18th April 2007, 10:29

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.