PDA

View Full Version : setBar ( QProgressBar * bar )



hvw59601
25th November 2007, 13:40
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!

jpn
25th November 2007, 14:02
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).

hvw59601
25th November 2007, 19:17
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.

hvw59601
25th November 2007, 19:55
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.

wysota
25th November 2007, 19:56
Set both minimum and maximum values to 0.

hvw59601
25th November 2007, 20:06
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:


progress = new QProgressBar( );
progress->setFormat(" ");
progress->setMaximum(0);
progress->setMinimum(0);
...
progressDialog->setBar(progress);


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

wysota
25th November 2007, 20:50
But why do you insist on placing your own bar on the dialog?

This is what I get using the following code:

#include <QProgressDialog>
#include <QApplication>

int main(int argc, char **argv){
QApplication app(argc, argv);
QProgressDialog dlg;
dlg.setRange(0,0);
dlg.exec();
return 0;
}

ShaChris23
29th July 2010, 00:09
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:



QProgressDialog dialog;
QProgressBar* progress = new QProgressBar(&dialog);
progress->setFormat(" ");
progress->setMaximum(0);
progress->setMinimum(0);
dialog.setBar(progress);


I hope that helps.