void MainWindow::on_pushButton_clicked()
{
QProgressDialog process(this);
process.setLabelText(tr("processing..."));
process.setRange(0,50000);
process.setModal(true);
process.setCancelButtonText(tr("cancel"));
process.show();
for(int i=0;i<50000;i++)
{
for(int j=0;j<20000;j++);
process.setValue(i);
if(process.wasCanceled())
break;
}
}
void MainWindow::on_pushButton_2_clicked()
{
int numFiles = 1000000;
QProgressDialog progress("Copying files...", "Abort Copy", 0, numFiles, this);
progress.setWindowModality(Qt::WindowModal);
//progress.show();
for (int i = 0; i < numFiles; i++) {
progress.setValue(i);
if (progress.wasCanceled())
break;
//... copy one file
}
progress.setValue(numFiles);
}
http://mobile.51cto.com/symbian-273449.htm
前一个没出现进度条,后一个出现了,但这是为什么呢?
试了半天,发现居然是5.32不行,5.7可以