Results 1 to 4 of 4

Thread: Progressdialog does not update?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    58
    Thanks
    1

    Default Progressdialog does not update?

    Hi.

    I've a long calculation that takes time.
    I tried using progressdialog to show users the status of the calculation.
    But the progressdialog apear on screen. after than it just doesnt update
    until the entire calculation finishes. Here's my codes. What could be wrong?

    QProgressDialog pd;
    pd.setRange(0,100000);
    pd.setLabelText("Long calculations...");
    pd.setValue(0);
    pd.show();


    In the calculation function, I've
    pd.setValue(somevalue) where somevalue is the value I obtained.
    pd.show()

    On the screen, what i see is just a progress dialog, which does not even have the bar moving at all. It sort of like those you see when something doesnt complete and freeze. And when all is done, the dialog just closes.

    What is really happening? Any advise?
    Thanks.

  2. #2
    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: Progressdialog does not update?

    You don't need to call show() every time you updated the value. What are the actual values of "somevalue" that you "obtained"? Are they in the range 0 to 100000?

    This, for example, works fine:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication app(argc, argv);
    6.  
    7. pd.setRange(0,100000);
    8. pd.setLabelText("Long calculations...");
    9. pd.setValue(0);
    10. pd.show();
    11.  
    12. for (int i = 0; i < 100000000; ++i) {
    13. if (i % 1000 == 0) {
    14. int somevalue = i / 1000;
    15. pd.setValue(somevalue);
    16. }
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

  3. #3
    Join Date
    Apr 2011
    Posts
    58
    Thanks
    1

    Default Re: Progressdialog does not update?

    I did what you wrote. Yes. It works when you're doing a simple loop. But once you place the pd.setValue(somevalue) in a more complex situation, the progress dialog does not get updated. Is this a bug? It looks to me that the refresh of the progressdialog is not given chance to update itself. Is there something we need to get this widget refresh or update?

  4. #4
    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: Progressdialog does not update?

    What "more complex situation" is going to stop the progress bar updating? The progress bar setValue() call ensures that any pending repaint is run before returning.

    Is the call to setValue() actually being called? Are the values in range?

Similar Threads

  1. Replies: 2
    Last Post: 29th September 2010, 17:44
  2. how to use update()?
    By zgulser in forum Qt Programming
    Replies: 0
    Last Post: 6th February 2009, 09:45
  3. Is Update() the right way?
    By td in forum Newbie
    Replies: 1
    Last Post: 5th December 2008, 14:54
  4. update()
    By JeanC in forum Qt Programming
    Replies: 4
    Last Post: 11th February 2008, 16:12
  5. Update a row
    By dragon in forum Newbie
    Replies: 9
    Last Post: 17th January 2006, 17:11

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
  •  
Qt is a trademark of The Qt Company.