You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
431 lines
17 KiB
431 lines
17 KiB
'\" t
|
|
.TH TQProgressDialog 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
TQProgressDialog \- Feedback on the progress of a slow operation
|
|
.SH SYNOPSIS
|
|
\fC#include <tqprogressdialog.h>\fR
|
|
.PP
|
|
Inherits TQDialog.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBTQProgressDialog\fR ( TQWidget * creator = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQProgressDialog\fR ( const TQString & labelText, const TQString & cancelButtonText, int totalSteps, TQWidget * creator = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fB~TQProgressDialog\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetLabel\fR ( TQLabel * label )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetCancelButton\fR ( TQPushButton * cancelButton )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetBar\fR ( TQProgressBar * bar )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool wasCancelled () const \fI(obsolete)\fR"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBwasCanceled\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtotalSteps\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBprogress\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual TQSize \fBsizeHint\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQString \fBlabelText\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetAutoReset\fR ( bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBautoReset\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetAutoClose\fR ( bool b )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBautoClose\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBminimumDuration\fR () const"
|
|
.br
|
|
.in -1c
|
|
.SS "Public Slots"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "void \fBcancel\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBreset\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetTotalSteps\fR ( int totalSteps )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetProgress\fR ( int progress )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetProgress\fR ( int progress, int totalSteps )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetLabelText\fR ( const TQString & )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetCancelButtonText\fR ( const TQString & cancelButtonText )"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBsetMinimumDuration\fR ( int ms )"
|
|
.br
|
|
.in -1c
|
|
.SS "Signals"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "void cancelled () \fI(obsolete)\fR"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBcanceled\fR ()"
|
|
.br
|
|
.in -1c
|
|
.SS "Properties"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "bool \fBautoClose\fR - whether the dialog gets hidden by reset()"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBautoReset\fR - whether the progress dialog calls reset() as soon as progress() equals totalSteps()"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQString \fBlabelText\fR - the label's text"
|
|
.br
|
|
.ti -1c
|
|
.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 TQProgressDialog 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. TQProgressDialog 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 TQProgressDialog: modal and modeless.
|
|
.PP
|
|
Using a modal TQProgressDialog is simpler for the programmer, but you must call TQApplication::processEvents() or TQEventLoop::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:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQProgressDialog progress( "Copying files...", "Abort Copy", numFiles,
|
|
.br
|
|
this, "progress", TRUE );
|
|
.br
|
|
for ( int i = 0; i < numFiles; i++ ) {
|
|
.br
|
|
progress.setProgress( i );
|
|
.br
|
|
tqApp->processEvents();
|
|
.br
|
|
.br
|
|
if ( progress.wasCanceled() )
|
|
.br
|
|
break;
|
|
.br
|
|
//... copy one file
|
|
.br
|
|
}
|
|
.br
|
|
progress.setProgress( numFiles );
|
|
.fi
|
|
.PP
|
|
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 TQProgressBar in the status bar of your main window is often an alternative to a modeless progress dialog.
|
|
.PP
|
|
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:
|
|
.PP
|
|
.nf
|
|
.br
|
|
Operation::Operation( TQObject *parent = 0 )
|
|
.br
|
|
: TQObject( parent ), steps( 0 )
|
|
.br
|
|
{
|
|
.br
|
|
pd = new TQProgressDialog( "Operation in progress.", "Cancel", 100 );
|
|
.br
|
|
connect( pd, TQ_SIGNAL(canceled()), this, TQ_SLOT(cancel()) );
|
|
.br
|
|
t = new TQTimer( this );
|
|
.br
|
|
connect( t, TQ_SIGNAL(timeout()), this, TQ_SLOT(perform()) );
|
|
.br
|
|
t->start( 0 );
|
|
.br
|
|
}
|
|
.br
|
|
.br
|
|
void Operation::perform()
|
|
.br
|
|
{
|
|
.br
|
|
pd->setProgress( steps );
|
|
.br
|
|
//... perform one percent of the operation
|
|
.br
|
|
steps++;
|
|
.br
|
|
if ( steps > pd->totalSteps() )
|
|
.br
|
|
t->stop();
|
|
.br
|
|
}
|
|
.br
|
|
.br
|
|
void Operation::cancel()
|
|
.br
|
|
{
|
|
.br
|
|
t->stop();
|
|
.br
|
|
//... cleanup
|
|
.br
|
|
}
|
|
.fi
|
|
.PP
|
|
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 TQDialog, TQProgressBar, GUI Design Handbook: Progress Indicator, and Dialog Classes.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "TQProgressDialog::TQProgressDialog ( TQWidget * creator = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 )"
|
|
Constructs a progress dialog.
|
|
.PP
|
|
Default settings:
|
|
.TP
|
|
The label text is empty.
|
|
.TP
|
|
The cancel button text is (translated) "Cancel".
|
|
.TP
|
|
The total number of steps is 100.
|
|
.PP
|
|
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 TQDialog::TQDialog() 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.
|
|
.SH "TQProgressDialog::TQProgressDialog ( const TQString & labelText, const TQString & cancelButtonText, int totalSteps, TQWidget * creator = 0, const char * name = 0, bool modal = FALSE, WFlags f = 0 )"
|
|
Constructs a progress dialog.
|
|
.PP
|
|
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 TQDialog::TQDialog() 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 "TQProgressDialog::~TQProgressDialog ()"
|
|
Destroys the progress dialog.
|
|
.SH "bool TQProgressDialog::autoClose () const"
|
|
Returns TRUE if the dialog gets hidden by reset(); otherwise returns FALSE. See the "autoClose" property for details.
|
|
.SH "bool TQProgressDialog::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.
|
|
.SH "void TQProgressDialog::cancel ()\fC [slot]\fR"
|
|
Resets the progress dialog. wasCanceled() becomes TRUE until the progress dialog is reset. The progress dialog becomes hidden.
|
|
.SH "void TQProgressDialog::canceled ()\fC [signal]\fR"
|
|
This signal is emitted when the cancel button is clicked. It is connected to the cancel() slot by default.
|
|
.PP
|
|
See also wasCanceled.
|
|
.SH "void TQProgressDialog::cancelled ()\fC [signal]\fR"
|
|
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
|
|
.PP
|
|
Use canceled() instead.
|
|
.PP
|
|
Examples:
|
|
.)l network/ftpclient/ftpmainwindow.ui.h and progress/progress.cpp.
|
|
.SH "void TQProgressDialog::forceShow ()\fC [protected slot]\fR"
|
|
Shows the dialog if it is still hidden after the algorithm has been started and minimumDuration milliseconds have passed.
|
|
.PP
|
|
See also minimumDuration.
|
|
.SH "TQString TQProgressDialog::labelText () const"
|
|
Returns the label's text. See the "labelText" property for details.
|
|
.SH "int TQProgressDialog::minimumDuration () const"
|
|
Returns the time that must pass before the dialog appears. See the "minimumDuration" property for details.
|
|
.SH "int TQProgressDialog::progress () const"
|
|
Returns the current amount of progress made. See the "progress" property for details.
|
|
.SH "void TQProgressDialog::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 TQProgressDialog::setAutoClose ( bool b )"
|
|
Sets whether the dialog gets hidden by reset() to \fIb\fR. See the "autoClose" property for details.
|
|
.SH "void TQProgressDialog::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 TQProgressDialog::setBar ( TQProgressBar * 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.
|
|
.SH "void TQProgressDialog::setCancelButton ( TQPushButton * cancelButton )"
|
|
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.
|
|
.PP
|
|
See also setCancelButtonText().
|
|
.SH "void TQProgressDialog::setCancelButtonText ( const TQString & cancelButtonText )\fC [slot]\fR"
|
|
Sets the cancel button's text to \fIcancelButtonText\fR.
|
|
.PP
|
|
See also setCancelButton().
|
|
.SH "void TQProgressDialog::setLabel ( TQLabel * label )"
|
|
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.
|
|
.PP
|
|
See also labelText.
|
|
.PP
|
|
Example: progress/progress.cpp.
|
|
.SH "void TQProgressDialog::setLabelText ( const TQString & )\fC [slot]\fR"
|
|
Sets the label's text. See the "labelText" property for details.
|
|
.SH "void TQProgressDialog::setMinimumDuration ( int ms )\fC [slot]\fR"
|
|
Sets the time that must pass before the dialog appears to \fIms\fR. See the "minimumDuration" property for details.
|
|
.SH "void TQProgressDialog::setProgress ( int progress )\fC [slot]\fR"
|
|
Sets the current amount of progress made to \fIprogress\fR. See the "progress" property for details.
|
|
.SH "void TQProgressDialog::setProgress ( int progress, int totalSteps )\fC [slot]\fR"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Sets the current amount of progress to \fIprogress\fR and the total number of steps to \fItotalSteps\fR.
|
|
.PP
|
|
See also totalSteps.
|
|
.SH "void TQProgressDialog::setTotalSteps ( int totalSteps )\fC [slot]\fR"
|
|
Sets the total number of steps to \fItotalSteps\fR. See the "totalSteps" property for details.
|
|
.SH "TQSize TQProgressDialog::sizeHint () const\fC [virtual]\fR"
|
|
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.
|
|
.SH "int TQProgressDialog::totalSteps () const"
|
|
Returns the total number of steps. See the "totalSteps" property for details.
|
|
.SH "bool TQProgressDialog::wasCanceled () const"
|
|
Returns TRUE if the dialog was canceled; otherwise returns FALSE. See the "wasCanceled" property for details.
|
|
.SH "bool TQProgressDialog::wasCancelled () const"
|
|
Returns TRUE if the dialog was canceled; otherwise returns FALSE. See the "wasCancelled" property for details.
|
|
.SS "Property Documentation"
|
|
.SH "bool autoClose"
|
|
This property holds whether the dialog gets hidden by reset().
|
|
.PP
|
|
The default is TRUE.
|
|
.PP
|
|
See also autoReset.
|
|
.PP
|
|
Set this property's value with setAutoClose() and get this property's value with autoClose().
|
|
.SH "bool autoReset"
|
|
This property holds whether the progress dialog calls reset() as soon as progress() equals totalSteps().
|
|
.PP
|
|
The default is TRUE.
|
|
.PP
|
|
See also autoClose.
|
|
.PP
|
|
Set this property's value with setAutoReset() and get this property's value with autoReset().
|
|
.SH "TQString labelText"
|
|
This property holds the label's text.
|
|
.PP
|
|
The default text is TQString::null.
|
|
.PP
|
|
Set this property's value with setLabelText() and get this property's value with labelText().
|
|
.SH "int minimumDuration"
|
|
This property holds the time that must pass before the dialog appears.
|
|
.PP
|
|
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.
|
|
.PP
|
|
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 TQProgressDialog::totalSteps(); you can call setProgress() any number of times in-between.
|
|
.PP
|
|
\fBWarning:\fR If the progress dialog is modal (see TQProgressDialog::TQProgressDialog()), this function calls TQApplication::processEvents(), so take care that this does not cause undesirable re-entrancy in your code. For example, don't use a TQProgressDialog 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.
|
|
.PP
|
|
Use wasCanceled instead.
|
|
.PP
|
|
Get this property's value with wasCancelled().
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/tqprogressdialog.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqprogressdialog.3qt) and the Qt
|
|
version (3.3.8).
|