我正在开发一个主要是文件浏览器的应用程序。我需要在删除文件时创建进度指示以向用户显示进度。
我已经创建了一个,但它很丑而且没有按预期工作。
下面是进度的样子
这不是很性感...我希望有一种取消图标,并且在进度指示器周围有一个有更多空间的窗口,为什么不写一个文字:1/10、2/10...
我遇到的第二个问题是进度条似乎无法正常工作。进度不显示。
下面是使用的代码。QProgressBar 是我的 DialogBox 类中的一种方法。
void MyDialog::ProgressIndicator(uint32_t max_value) {
//ProgressInd = new QProgressBar();
ProgressInd.setRange(0,max_value);
ProgressInd.setValue(0);
ProgressInd.show();
}
void MyDialog::ProgressUpdate(uint32_t value) {
ProgressInd.setValue(value);
}
void MyDialog::ProgressClose() {
ProgressInd.close();
}
ProgressInd 在头文件中定义如下:
QProgressBar ProgressInd;
我在我的代码中使用 ProgresBar:
TreeBox->ProgressIndicator(item.count());
for (int i=0; i<item.count();i++) {
myItem = dynamic_cast<MyTreeWidgetItem*>(item[i]);
if((myItem->item_id == INVALID) || (myItem->id == INVALID)) {
/* Shouldn't happened as id must be filed at creation */
/* safety mechanism */
delete myItem;
}
else {
error = m_device.DeleteFile(myItem_id);
if(error == ERROR_NONE)
{
delete myItem;
}
else {
TreeBox->NotificationBox("File(s) deletion Failed");
TreeBox->ProgressClose();
return;
}
}
TreeBox->ProgressUpdate(i++);
}
TreeBox->ProgressClose();