×
Namespaces

Variants
Actions
Revision as of 18:28, 6 June 2009 by savaj (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Create progress dialog using QProgressDialog

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia 5800
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Symbian
Article
Keywords: QProgressDialog
Created: (06 Jun 2009)
Last edited: savaj (06 Jun 2009)


Contents

Overview

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.

Preconditions

Source code

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();
}


Other useful methods of QProgressDialog

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.

Postconditions

The code snippet is expected to show a progress dialog with cancel button, as shown in below image.

QtProgressDialog.PNG

Code Example

External reference

133 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×