Results 1 to 8 of 8

Thread: setBar ( QProgressBar * bar )

  1. #1
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default setBar ( QProgressBar * bar )

    Hi,

    I now use QProgressDialog to create a modeless progress dialog.

    But I want to change what that shows by default: percentages.

    So I have to use setBar() + I have a question:

    When I use setBar() who does the progress counting with setValue() now, the progress bar or the progress dialog?

    Thanks!

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: setBar ( QProgressBar * bar )

    Quote Originally Posted by hvw59601 View Post
    So I have to use setBar() + I have a question:

    When I use setBar() who does the progress counting with setValue() now, the progress bar or the progress dialog?
    Hmm, what do you mean? QProgressDialog is a wrapper dialog around the progress bar. Calling QProgressDialog::setValue() calls further QProgressBar::setValue(). However, you should use QProgressDialog::setValue(), not QProgressBar::setValue() directly, because QProgressDialog::setValue() does other things too (like handles QProgressDialog::minimumDuration).
    J-P Nurmi

  3. #3
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default Re: setBar ( QProgressBar * bar )

    However, you should use QProgressDialog::setValue()
    That's the answer I was looking for. It wasn't clear to me, because you can setValue() with both QProgressBar and QProgressDialog.
    Thanks again.

  4. #4
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default Re: setBar ( QProgressBar * bar )

    But I get a QProgressDialog without a bar.

    Let me rephrase the question: what is the minimum I have to do, given I have a working QProgressDialog, to get a bar that shows nothing: no percentage, nothing, that just moves.

  5. #5
    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: setBar ( QProgressBar * bar )

    Set both minimum and maximum values to 0.

  6. #6
    Join Date
    Oct 2007
    Posts
    11
    Thanks
    4

    Default Re: setBar ( QProgressBar * bar )

    Still no bar.

    I have a working QProgressDialog. It shows percentages. The default. Which I don't want.

    So then I add in the application constructor:

    Qt Code:
    1. progress = new QProgressBar( );
    2. progress->setFormat(" ");
    3. progress->setMaximum(0);
    4. progress->setMinimum(0);
    5. ...
    6. progressDialog->setBar(progress);
    To copy to clipboard, switch view to plain text mode 

    and the result is a QProgressDialog without a bar at all.

  7. #7
    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: setBar ( QProgressBar * bar )

    But why do you insist on placing your own bar on the dialog?

    This is what I get using the following code:
    Qt Code:
    1. #include <QProgressDialog>
    2. #include <QApplication>
    3.  
    4. int main(int argc, char **argv){
    5. QApplication app(argc, argv);
    6. dlg.setRange(0,0);
    7. dlg.exec();
    8. return 0;
    9. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

  8. #8
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setBar ( QProgressBar * bar )

    hvw59601,

    I ran into the same problem as yours. The problem is you have to pass the pointer to QProgressDialog to the constructor of QProgressBar.

    Like this:

    Qt Code:
    1. QProgressBar* progress = new QProgressBar(&dialog);
    2. progress->setFormat(" ");
    3. progress->setMaximum(0);
    4. progress->setMinimum(0);
    5. dialog.setBar(progress);
    To copy to clipboard, switch view to plain text mode 

    I hope that helps.

Similar Threads

  1. QProgressBar busy indicator
    By Michiel in forum Qt Tools
    Replies: 2
    Last Post: 1st August 2007, 16:54
  2. QProgressBar: don't understand in details, help me !!!
    By haconganh in forum Qt Programming
    Replies: 5
    Last Post: 10th May 2007, 08:07
  3. QProgressbar and ... Spacebar
    By RafalR in forum Qt Programming
    Replies: 6
    Last Post: 11th September 2006, 18:40
  4. setOrientation QProgressBar
    By fellobo in forum Qt Tools
    Replies: 4
    Last Post: 15th February 2006, 23:32
  5. QProgressBar & 200%
    By Dmitry in forum Qt Programming
    Replies: 2
    Last Post: 20th January 2006, 11:33

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.