⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qprogressdialog.3qt

📁 Qt/Embedded是一个多平台的C++图形用户界面应用程序框架
💻 3QT
字号:
.TH QProgressDialog 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS.  All rights reserved.  See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQProgressDialog \- Provides feedback on the progress of a slow operation.SH SYNOPSIS.br.PP\fC#include <qprogressdialog.h>\fR.PPInherits QSemiModal..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQProgressDialog\fR ( QWidget * " "parent" "=0, const char * " "name" "=0, bool " "modal" "=FALSE, WFlags " "f" "=0 ) ".br.ti -1c.BI "\fBQProgressDialog\fR ( const QString & " "labelText" ", const QString & " "cancelButtonText" ", int " "totalSteps" ", QWidget * " "parent" "=0, const char * " "name" "=0, bool " "modal" "=FALSE, WFlags " "f" "=0 ) ".br.ti -1c.BI "\fB~QProgressDialog\fR () ".br.ti -1c.BI "void \fBsetLabel\fR ( QLabel * ) ".br.ti -1c.BI "void \fBsetCancelButton\fR ( QPushButton * ) ".br.ti -1c.BI "void \fBsetBar\fR ( QProgressBar * ) ".br.ti -1c.BI "bool \fBwasCancelled\fR () const".br.ti -1c.BI "int \fBtotalSteps\fR () const".br.ti -1c.BI "int \fBprogress\fR () const".br.ti -1c.BI "virtual QSize \fBsizeHint\fR () const".br.ti -1c.BI "QString \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 \fBsetLabelText\fR ( const QString & ) ".br.ti -1c.BI "void \fBsetCancelButtonText\fR ( const QString & ) ".br.ti -1c.BI "void \fBsetMinimumDuration\fR ( int ms ) ".br.in -1c.SS "Signals".in +1c.ti -1c.BI "void \fBcancelled\fR () ".br.in -1c.SS "Protected Slots".in +1c.ti -1c.BI "void \fBforceShow\fR () ".br.in -1c.SS "Properties"<table border=1 cellpadding=3 cellspacing=0> <tr><th>Type<th>Name<th>READ<th>WRITE<th>Options <tr><td>bool<td>wasCancelled<td>wasCancelled<td>&nbsp;<td>&nbsp; <tr><td>int<td>totalSteps<td>totalSteps<td>setTotalSteps<td>&nbsp; <tr><td>int<td>progress<td>progress<td>setProgress<td>&nbsp; <tr><td>bool<td>autoReset<td>autoReset<td>setAutoReset<td>&nbsp; <tr><td>bool<td>autoClose<td>autoClose<td>setAutoClose<td>&nbsp; <tr><td>QString<td>labelText<td>labelText<td>setLabelText<td>&nbsp; </table>.SH DESCRIPTIONProvides feedback on the progress of a slow operation..PPA progress dialog is used to give the user an indication of how long an operation is going to take to perform, and to reassure them that the application has not frozen. It also gives the user an opportunity to abort the operation..PPA potential problem with progress dialogs is that it is difficult to know when to use them, as operations take different amounts of time on different computer 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)..PPUse 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 eg. the number of files copied, the number of bytes received, or the number of iterations through the main loop of your algorithm. You must call setProgress() with parameter 0 initially, and with parameter totalSteps() at the end..PPThe dialog will automatically be reset and hidden at the end of the operation, Use setAutoReset() and setAutoClose() to change this behavior..PPThere are two ways of using QProgressDialog, modal and non-modal..PPUsing a modal QProgressDialog is simpler for the programmer, but you have to call qApp->processEvents() to keep the event loop running and prevent the application from freezing. Do the operation in a loop, calling setProgress() at intervals, and checking for cancellation with wasCancelled()..PPExample:.PP.nf.br    QProgressDialog progress( "Copying files...", "Abort Copy", numFiles,.br                                this, "progress", TRUE );.br    for (int i=0; i<numFiles; i++) {.br        progress.setProgress( i );.br        qApp->processEvents();.br.br        if ( progress.wasCancelled() ).br            break;.br        ... // copy one file.br    }.br    progress.setProgress( numFiles );.fi.PPA non-modal 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 QTimer (or QObject::timerEvent()), QSocketNotifier, or QUrlOperator; or performed in a separate thread. A QProgressBar in the status bar of your main window is often an alternative to a non-modal progress dialog..PPYou need an event loop to be running. Connect the cancelled() signal to a slot that stops the operation, and call setProgress() at intervals..PPExample:.PP.nf.br  Operation::Operation( QObject *parent = 0 ).br      : QObject( parent ), steps(0).br  {.br      pd = new QProgressDialog( "Operation in progress.", "Cancel", 100 );.br      connect( pd, SIGNAL(cancelled()), this, SLOT(cancel()) );.br      t = new QTimer( this );.br      connect( t, SIGNAL(timeout()), this, 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.PPIn both modes, the progress dialog may be customized by replacing the child widgets with custom widgets, using setLabel(), setBar() and setCancelButton(). The functions setLabelText() and setCancelButtonText() sets the texts shown..PP<img src=qprogdlg-m.png> <img src=qprogdlg-w.png>.PPSee also QDialog, QProgressBar and GUI Design Handbook: Progress Indicator.PPExamples:.(lprogress/progress.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QProgressDialog::QProgressDialog ( QWidget * creator=0, const char * name=0, bool modal=FALSE, WFlags f=0 )"Constructs a progress dialog..PPDefault settings:.TPThe label text is empty..TPThe cancel button text is "Cancel"..TPThe total number of steps is 100..PP\fIparent, name, modal,\fR and \fIf\fR are sent to the QSemiModal::QSemiModal() constructor. Note that if \fImodal\fR is FALSE (the default), you will need to have an event loop proceeding for any redrawing of the dialog to occur. If it is TRUE, the dialog ensures events are processed when needed..PPSee also setLabelText(), setLabel(), setCancelButtonText(), setCancelButton() and setTotalSteps()..SH "QProgressDialog::QProgressDialog ( const QString & labelText, const QString & cancelButtonText, int totalSteps, QWidget * creator=0, const char * name=0, bool modal=FALSE, WFlags f=0 )"Constructs a progress dialog..PP\fIlabelText\fR is text telling the user what is progressing..PP\fIcancelButtonText\fR is the text on the cancel button, or 0 if no cancel button is to be shown..PP\fItotalSteps\fR is the total number of steps in the operation of which this progress dialog shows the progress. For example, if the operation is to examine 50 files, this value would be 50, then before examining the first file, call setProgress(0), and after examining the last file call setProgress(50)..PP\fIname, modal,\fR and \fIf\fR are sent to the QSemiModal::QSemiModal() constructor. Note that if \fImodal\fR is FALSE (the default), you will need to have an event loop proceeding for any redrawing of the dialog to occur. If it is TRUE, the dialog ensures events are processed when needed..PPSee also setLabelText(), setLabel(), setCancelButtonText(), setCancelButton() and setTotalSteps()..SH "QProgressDialog::~QProgressDialog ()"Destructs the progress dialog..SH "bool QProgressDialog::autoClose () const"Returns if the dialog gets hidden by reset()..PPSee also setAutoClose()..SH "bool QProgressDialog::autoReset () const"Returns if the dialog resets itself when progress() equals totalSteps()..PPSee also setAutoReset()..SH "void QProgressDialog::cancel () \fC[slot]\fR"Reset the progress dialog. wasCancelled() becomes TRUE until the progress dialog is reset. The progress dialog becomes hidden..SH "void QProgressDialog::cancelled () \fC[signal]\fR"This signal is emitted when the cancel button is clicked. It is connected to the cancel() slot by default..PPSee also wasCancelled()..SH "void QProgressDialog::closeEvent ( QCloseEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QProgressDialog::forceShow () \fC[protected slot]\fR"Shows the dialog if it is still hidden after the algorithm has been started and the minimumDuration is over..PPSee also setMinimumDuration()..SH "QString QProgressDialog::labelText () const"Returns the labels text..PPSee also setLabelText..SH "int QProgressDialog::minimumDuration () const"Returns the currently set minimum duration for the QProgressDialog.PPSee also setMinimumDuration()..SH "int QProgressDialog::progress () const"Returns the current amount of progress, or -1 if the progress counting has not started..PPSee also setProgress()..SH "void QProgressDialog::reset () \fC[slot]\fR"Reset the progress dialog. The progress dialog becomes hidden if autoClose() is TRUE..PPSee also setAutoClose() and setAutoReset()..SH "void QProgressDialog::resizeEvent ( QResizeEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QProgressDialog::setAutoClose ( bool b )"If you set \fIb\fR to TRUE, the dialog gets closed (hidden) if reset() is called, else this does not happen..PPSee also autoClose() and setAutoReset()..SH "void QProgressDialog::setAutoReset ( bool b )"If you set \fIb\fR to TRUE, the progress dialog calls reset() if progress() equals totalSteps(), if you set it to FALSE, this does not happen..PPSee also autoReset() and setAutoClose()..SH "void QProgressDialog::setBar ( QProgressBar * bar )"Sets the progress bar widget. The progress dialog resizes to fit. The progress bar becomes owned by the progress dialog and will be deleted when necessary..SH "void QProgressDialog::setCancelButton ( QPushButton * cancelButton )"Sets the cancellation button. The button becomes owned by the progress dialog and will be deleted when necessary, so do not pass the address of an object on the stack..PPSee also setCancelButtonText()..SH "void QProgressDialog::setCancelButtonText ( const QString & cancelButtonText ) \fC[slot]\fR"Sets the cancellation button text..PPSee also setCancelButton()..SH "void QProgressDialog::setLabel ( QLabel * label )"Sets the label. 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..PPSee also setLabelText()..PPExamples:.(lprogress/progress.cpp.)l.SH "void QProgressDialog::setLabelText ( const QString & text ) \fC[slot]\fR"Sets the label text. The progress dialog resizes to fit..PPSee also setLabel()..SH "void QProgressDialog::setMinimumDuration ( int ms ) \fC[slot]\fR"Sets the minimum duration to \fIms\fR milliseconds. The dialog will not appear if the anticipated duration of the progressing task is less than the minimum duration..PPIf \fIms\fR is 0 the dialog is always shown as soon as any progress is set..PPSee also minimumDuration()..PPExamples:.(lprogress/progress.cpp.)l.SH "void QProgressDialog::setProgress ( int progress ) \fC[slot]\fR"Sets the current amount of progress made to \fIprog\fR units of the total number of steps. For the progress dialog to work correctly, you must at least call this with the parameter 0 initially, then later with QProgressDialog::totalSteps(), and you may call it 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 to your code. For example, don't use a QProgressDialog inside a paintEvent()!.PPSee also progress()..PPExamples:.(lprogress/progress.cpp.)l.SH "void QProgressDialog::setTotalSteps ( int totalSteps ) \fC[slot]\fR"Sets the total number of steps..PPSee also totalSteps() and QProgressBar::setTotalSteps()..SH "void QProgressDialog::showEvent ( QShowEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QSize QProgressDialog::sizeHint () const \fC[virtual]\fR"Returns a size which fits the contents of the progress dialog. The progress dialog resizes itself as required, so this should not be needed in user code..PPReimplemented from QWidget..SH "void QProgressDialog::styleChange ( QStyle & s ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "int QProgressDialog::totalSteps () const"Returns the total number of steps..PPSee also setTotalSteps() and QProgressBar::totalSteps()..PPExamples:.(lprogress/progress.cpp.)l.SH "bool QProgressDialog::wasCancelled () const"Returns the TRUE if the dialog was cancelled, otherwise FALSE..PPSee also setProgress(), cancel() and cancelled()..PPExamples:.(lprogress/progress.cpp.)l.SH "SEE ALSO".BR http://doc.trolltech.com/qprogressdialog.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/.  See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -