| ID | ... | Creation date | 06 June 2009 |
| Platform | S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition | Tested on devices | Nokia 5800 |
| Category | Qt for Symbian | Subcategory |
| Keywords (APIs, classes, methods, functions): QProgressDialog |
The QProgressDialog class provides feedback on the progress of a slow operation. 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. Although QProgressDialog is similar to QProgressBar, it give the user an opportunity to abort the operation, while QProgressBar will just show progress. Here you can check How to use QProgressBar.
This snippet can be self-signed. As it not use any API which require signing.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ProgressDialog w;
w.showMaximized();
QVBoxLayout* layout = new QVBoxLayout;
QWidget* win = new QWidget;
//The minimum and maximum is the number of steps in the operation for which this progress dialog shows progress.
//for example here 0 and 100.
QProgressDialog* progress = new QProgressDialog("Fetching data...", "Cancel", 0, 100);
//Set dialog as modal dialog, if you want.
progress->setWindowModality(Qt::WindowModal);
layout->addWidget(progress,Qt::AlignCenter);
win->setLayout(layout);
for (int i = 0; i < 100; i++)
{
//set progress value.
progress->setValue(i);
win->show();
//if user click cancel button of dialog.
if (progress->wasCanceled())
break;
}
progress->setValue(100);
win->show();
return a.exec();
}
Slots cancel () is resets the progress dialog. Signal canceled () is emitted when the cancel button is clicked. It is connected to the cancel() slot by default.
The code snippet is expected to show a progress dialog with cancel button, as shown in below image.