Busy Indicator using QProgressDialog??
I am trying to copy /dev/mem to another location and want a 'busy indicator progressDialog' (in which a fluid moves to and fro in a progress bar) to show that the copying process is going on.
Qt provides two widgets for showing progress
1. QProgressBar
2. QProgressDialog
if we set both setMinimum and setMaximum equal to zero in 'QProgressBar' then i get the to and fro functionality but although setMaximum and setMaximum properties are available for 'QProgressDialog' too; setting them to zero do not give me the required functionality.
I hope i made myself clear. Please suggest some solution..
Following link contains the snippet of the code
Code:
progress.setWindowModality(Qt::WindowModal);
progress.setMinimumDuration(0);
QString program
= "dd if=/dev/mem of=/home/usman/copiedFile.dt"
progress.setRange(0, 1);
progress.setValue(0);
progress.setRange(0, 0);
Re: Busy Indicator using QProgressDialog??
looking at the QProgressDialog docs...
Code:
Progress starts at the value set by setMinimum(), and the progress dialog shows that the operation has finished when you call setValue() with the value set by setMaximum() as its argument.
The dialog automatically resets and hides itself at the end of the operation. Use setAutoReset() and setAutoClose() to change this behavior.
so it looks like this dialog is not ment for showing busy states..
try this if it works...i am not too sure
Code:
progressDialog->setBar(bar);
bar->setMinimum(0);bar->setMaximum(0);
progressDialog->show();
as a last resort u can make your own dialog class .
Re: Busy Indicator using QProgressDialog??
Set the range to (0,0) in the first place (before calling setValue) and I think you should obtain what you want.
Re: Busy Indicator using QProgressDialog??
setting the value to (0,0) did not solve the problem. And i tried the setBar(QProgressBar *bar) too, suggested by MrDeath, but it also did not result in some thing fruitful.
:(
Re: Busy Indicator using QProgressDialog??
After don't having much luck with QProgressDialog...i now turned to ProgressDialog but encountered another problem.
I got the to and fro movement of a blue fluid in the progress bar, depicting the busy state, but i want to make the bar filled with blue fluid at the completion of the operation i am performing.
But problem is that for the busy indicator i need to setMaximum=0. And at the end of process i need to set setMaximum to say 100 and setValue to 100 too.
When i run my app, the later setMaximum seems to overide the previous setMaximum and as soon as the app runs, the progressBar gives a 100% reading with the blue fluid filled comletely in it, without showing any busy indicatior.
If i use the waitForFinished() function of QProcess to wait until my task is finished (and then setting the setMaximum=100 and setValue=100) then my app gets frozen and i neither get a busy indicatior nor a blue fluid filled bar.
Following is the code
Code:
progressBar->setMaximum(0);
progressBar->setMinimum(0);
QString program
= "dd if=/dev/mem of=";
program.append(lineEdit_saveAt->text());
myProcess->start(program);
//if myProcess->waitForFinished() {
progressBar->setMaximum(100);
progressBar->setValue(100);
//}
Please suggest something. Thanks
Re: Busy Indicator using QProgressDialog??
Quote:
setting the value to (0,0) did not solve the problem.
wysota told you to set the range, not value.
Quote:
If i use the waitForFinished() function of QProcess to wait until my task is finished (and then setting the setMaximum=100 and setValue=100) then my app gets frozen and i neither get a busy indicatior nor a blue fluid filled bar.
make a slot in which you set the progress filled (max = 100, value = 100) and connect QProcess::finished() to it.
Re: Busy Indicator using QProgressDialog??
same problem encountered .. in progressDialog setting range or value to 0 is not working .. but its working for QProgressBar ...
Re: Busy Indicator using QProgressDialog??
Quote:
Originally Posted by
qtzcute
setting the value to (0,0) did not solve the problem. And i tried the setBar(QProgressBar *bar) too, suggested by MrDeath, but it also did not result in some thing fruitful.
:(
Works for me...
Code:
#include <QtGui>
int main(int argc, char **argv){
dlg.setRange(0,0);
dlg.exec();
}
Re: Busy Indicator using QProgressDialog??
@falzip
Thanks..that worked.
@wysota
I wasn't using dlg.exec(). Most probably that was the reason. Thanks for helping.
Re: Busy Indicator using QProgressDialog??
why so difficult???
use
Code:
progress.setWindowModality(Qt::WindowModal);
progress.setLabelText("working...");
progress.setCancelButton(0);
progress.setRange(0,0);
progress.setMinimumDuration(0);
progress.show();
//do what u want...
progress.cancel();
Re: Busy Indicator using QProgressDialog??
Quote:
Originally Posted by
Qiieha
why so difficult???
use
Code:
progress.setWindowModality(Qt::WindowModal);
progress.setLabelText("working...");
progress.setCancelButton(0);
progress.setRange(0,0);
progress.setMinimumDuration(0);
progress.show();
//do what u want...
progress.cancel();
Did you noticed that this thread is 2 years old and the OP got the answer as well.
Re: Busy Indicator using QProgressDialog??
I know, but his solution is intricate, and lots of people google for "QProgressDialog busy indicator" and hit on this thread.
So I think it's useful, if there is another working solution, isn't it? :)
Re: Busy Indicator using QProgressDialog??
well, if you try your code
- progress.show();
- //do what u want...
- progress.cancel();
You will not see the animation in the progress dialog because the event loop would be blocked util your "//do what u want" is finished.
Re: Busy Indicator using QProgressDialog??
no, I use my code in a couple of programs and it works.