PDA

View Full Version : Problem with QProgressBar



agupta
31st December 2010, 12:45
Hi...
I am new to QT. I am trying to create an application which reads the data from the database. While retreving the data i want to show the progressbar.
Since i don't know how much time my application take for retreving the data from different databases, so I m using the busy Progressbar by setting Maximum/Minimum to 0/0.

Code:

"void MainWindow::on_Start_button_clicked()
{
static int count = 0;
progressBar->setMaximum(0);
progressBar->setMinimum(0);
progressBar->setValue(++count);
}

void MainWindow::on_Stop_button_clicke()
{
progressBar->reset();
}"

using the above code I am able to see the busy ProgressBar but on clicking the Stop button I am not able to reset the progressBar... it still keep me showing the busy.

Please let me know what extra i have to do for resetting the progressBar.

totem
31st December 2010, 14:58
what do you mean by "resetting" ? If you don't change 0-value for min/max, your QProgressBar will never change its behavior (busy indicator).
If you want to set an empty progress bar, change max to non-0 value and call reset()

agupta
1st January 2011, 05:15
Thanks for your reply... :)
As per your suggestion i used the following code

void MainWindow::on_Stop_button_clicked()
{
progressBar->setMaximum(1);
progressBar->reset();
}

This code worked fine for me.