[Qt-interest] QProgressBar kind of functionality withQProgressDialog (Size of file being copied not known)
Ben Swerts
benswerts at telenet.be
Thu May 28 20:09:40 CEST 2009
HI Usman,
I hope you understood from the other posts that you need to let the
eventloop spin (e.g. QApplication::processEvents) such that the
QProgressDialog can be shown. There are, however, a few other caveats you
should be aware of:
- QProgressDialog is only shown after the specified minimumDuration(). The
default value is 4 seconds, but as you mentioned that the process runs for a
few minutes you don't have to worry about that.
- The progress bar can be made moving by setting the same minimum and
maximum value. I had to perform a workaround (Qt 4.3.3) to actually get it
to move in the QProgressDialog:
progressDialog->setRange(0, 1);
progressDialog->setValue(0);
progressDialog->setRange(0, 0);
I don't know whether this fix is still needed with the latest version of Qt.
Hope it helps.
Greets,
Ben
> Let me rephrase my question:
>
> Can i show the progress of my operation with the help of a blue fluid
> moving to and from in the bar of QProgressDialog?
>
> I want such functionality because i don't know the size of the operation.
>
> I went through QProgressDialog class reference but invain. Kindly suggest
> something.
>
> Thanks
>
>
> On Mon, May 25, 2009 at 12:33 PM, Usman Ajmal <uzmanajmal at gmail.com>
> wrote:
>
>
> Hi,
> I set setMaximum() and setMinimum(), of QProgressBar, equal to zero
> which gave be the ability to show a kinda progress without showing the
> percentage of the operation completed. It only showed a blue fluid moving
> to and from in the bar which showed that something is being copied.
>
> Now i want to have the same kind of progress presentation with
> QProgressDialog but i could not see anything showing up when i start the
> operation. I don't see even the dialog.
>
> Following z the snippet from my code: In following code 'line' is
> QString and 'image' is QTextStream.
>
> QProgressDialog progress("Copying files...", "Abort Copy", 0, 0,
> this);
> while (!line.isNull())
> {
> if (progress.wasCanceled())
> break;
> line = in.readLine();
> image<<line<<endl;
>
> }
>
> What else do i need to add here?
>
> Thanks.
>
> --
> Usman
>
>
More information about the Qt-interest-old
mailing list