.BI "int \fBminimumDuration\fR - the time that must pass before the dialog appears"
.br
.ti -1c
.BI "int \fBprogress\fR - the current amount of progress made"
.br
.ti -1c
.BI "int \fBtotalSteps\fR - the total number of steps"
.br
.ti -1c
.BI "bool \fBwasCanceled\fR - whether the dialog was canceled \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "bool wasCancelled - whether the dialog was canceled \fI(read " "only" ")\fR \fI(obsolete)\fR"
.br
.in -1c
.SS "Protected Slots"
.in +1c
.ti -1c
.BI "void \fBforceShow\fR ()"
.br
.in -1c
.SH DESCRIPTION
The QProgressDialog class provides feedback on the progress of a slow operation.
.PP
A progress dialog is used to give the user an indication of how long an operation is going to take, and to demonstrate that the application has not frozen. It can also give the user an opportunity to abort the operation.
.PP
A common problem with progress dialogs is that it is difficult to know when to use them; operations take different amounts of time on different hardware. QProgressDialog offers a solution to this problem: it estimates the time the operation will take (based on time for steps), and only shows itself if that estimate is beyond minimumDuration() (4 seconds by default).
.PP
Use setTotalSteps() (or the constructor) to set the number of" steps" in the operation and call setProgress() as the operation progresses. The step value can be chosen arbitrarily. It can be the number of files copied, the number of bytes received, the number of iterations through the main loop of your algorithm, or some other suitable unit. Progress starts at 0, and the progress dialog shows that the operation has finished when you call setProgress() with totalSteps() as its argument.
.PP
The dialog automatically resets and hides itself at the end of the operation. Use setAutoReset() and setAutoClose() to change this behavior.
.PP
There are two ways of using QProgressDialog: modal and modeless.
.PP
Using a modal QProgressDialog is simpler for the programmer, but you must call QApplication::processEvents() or QEventLoop::processEvents(ExcludeUserInput) to keep the event loop running to ensure that the application doesn't freeze. Do the operation in a loop, call setProgress() at intervals, and check for cancellation with wasCanceled(). For example:
A modeless progress dialog is suitable for operations that take place in the background, where the user is able to interact with the application. Such operations are typically based on TQTimer (or TQObject::timerEvent()), TQSocketNotifier, or TQUrlOperator; or performed in a separate thread. A QProgressBar in the status bar of your main window is often an alternative to a modeless progress dialog.
You need to have an event loop to be running, connect the canceled() signal to a slot that stops the operation, and call setProgress() at intervals. For example:
In both modes the progress dialog may be customized by replacing the child widgets with custom widgets by using setLabel(), setBar(), and setCancelButton(). The functions setLabelText() and setCancelButtonText() set the texts shown.
.PP
.ce 1
.B "[Image Omitted]"
.PP
.ce 1
.B "[Image Omitted]"
.PP
See also QDialog, QProgressBar, GUI Design Handbook: Progress Indicator, and Dialog Classes.
The \fIcreator\fR argument is the widget to use as the dialog's parent. The \fIname\fR, \fImodal\fR, and the widget flags, \fIf\fR, are passed to the QDialog::QDialog() constructor. If \fImodal\fR is FALSE (the default), you must have an event loop proceeding for any redrawing of the dialog to occur. If \fImodal\fR is TRUE, the dialog ensures that events are processed when needed.
.PP
See also labelText, setLabel(), setCancelButtonText(), setCancelButton(), and totalSteps.
The \fIlabelText\fR is text used to remind the user what is progressing.
.PP
The \fIcancelButtonText\fR is the text to display on the cancel button, or 0 if no cancel button is to be shown.
.PP
The \fItotalSteps\fR is the total number of steps in the operation for which this progress dialog shows progress. For example, if the operation is to examine 50 files, this value would be 50. Before examining the first file, call setProgress(0). As each file is processed call setProgress(1), setProgress(2), etc., finally calling setProgress(50) after examining the last file.
.PP
The \fIcreator\fR argument is the widget to use as the dialog's parent. The \fIname\fR, \fImodal\fR, and widget flags, \fIf\fR, are passed to the QDialog::QDialog() constructor. If \fImodal\fR is FALSE (the default), you will must have an event loop proceeding for any redrawing of the dialog to occur. If \fImodal\fR is TRUE, the dialog ensures that events are processed when needed.
.PP
See also labelText, setLabel(), setCancelButtonText(), setCancelButton(), and totalSteps.
.SH "QProgressDialog::~QProgressDialog ()"
Destroys the progress dialog.
.SH "bool QProgressDialog::autoClose () const"
Returns TRUE if the dialog gets hidden by reset(); otherwise returns FALSE. See the "autoClose" property for details.
.SH "bool QProgressDialog::autoReset () const"
Returns TRUE if the progress dialog calls reset() as soon as progress() equals totalSteps(); otherwise returns FALSE. See the "autoReset" property for details.
Returns the time that must pass before the dialog appears. See the "minimumDuration" property for details.
.SH "int QProgressDialog::progress () const"
Returns the current amount of progress made. See the "progress" property for details.
.SH "void QProgressDialog::reset ()\fC [slot]\fR"
Resets the progress dialog. The progress dialog becomes hidden if autoClose() is TRUE.
.PP
See also autoClose and autoReset.
.PP
Example: network/ftpclient/ftpmainwindow.ui.h.
.SH "void QProgressDialog::setAutoClose ( bool b )"
Sets whether the dialog gets hidden by reset() to \fIb\fR. See the "autoClose" property for details.
.SH "void QProgressDialog::setAutoReset ( bool b )"
Sets whether the progress dialog calls reset() as soon as progress() equals totalSteps() to \fIb\fR. See the "autoReset" property for details.
.SH "void QProgressDialog::setBar ( QProgressBar * bar )"
Sets the progress bar widget to \fIbar\fR. The progress dialog resizes to fit. The progress dialog takes ownership of the progress \fIbar\fR which will be deleted when necessary, so do not use a progress bar allocated on the stack.
Sets the cancel button to the push button, \fIcancelButton\fR. The progress dialog takes ownership of this button which will be deleted when necessary, so do not pass the address of an object that is on the stack, i.e. use new() to create the button.
Sets the label to \fIlabel\fR. The progress dialog resizes to fit. The label becomes owned by the progress dialog and will be deleted when necessary, so do not pass the address of an object on the stack.
Returns a size that fits the contents of the progress dialog. The progress dialog resizes itself as required, so you should not need to call this yourself.
If the expected duration of the task is less than the minimumDuration, the dialog will not appear at all. This prevents the dialog popping up for tasks that are quickly over. For tasks that are expected to exceed the minimumDuration, the dialog will pop up after the minimumDuration time or as soon as any progress is set.
If set to 0, the dialog is always shown as soon as any progress is set. The default is 4000 milliseconds.
.PP
Set this property's value with setMinimumDuration() and get this property's value with minimumDuration().
.SH "int progress"
This property holds the current amount of progress made.
.PP
For the progress dialog to work as expected, you should initially set this property to 0 and finally set it to QProgressDialog::totalSteps(); you can call setProgress() any number of times in-between.
.PP
\fBWarning:\fR If the progress dialog is modal (see QProgressDialog::QProgressDialog()), this function calls QApplication::processEvents(), so take care that this does not cause undesirable re-entrancy in your code. For example, don't use a QProgressDialog inside a paintEvent()!
.PP
See also totalSteps.
.PP
Set this property's value with setProgress() and get this property's value with progress().
.SH "int totalSteps"
This property holds the total number of steps.
.PP
The default is 0.
.PP
Set this property's value with setTotalSteps() and get this property's value with totalSteps().
.SH "bool wasCanceled"
This property holds whether the dialog was canceled.
.PP
Get this property's value with wasCanceled().
.PP
See also progress.
.SH "bool wasCancelled"
This property holds whether the dialog was canceled.
.PP
\fBThis property is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.