- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在我的程序中选择并加载了一些大的 Dicom 文件。整个加载过程需要很长时间(取决于文件的数量,但如果文件很多,整个过程可能需要几分钟以上)。当文件上传正在进行时,我想显示一个“等待符号”或类似的东西。我进行了搜索,但没有得到任何确定的信息。
我选择和上传部分的代码如下:
void MainWindow::showTheSelectedList()
{
QFileDialog * fileDialog = new QFileDialog(this);
fileDialog->setFileMode(QFileDialog::ExistingFiles);
QListView* list = fileDialog->findChild<QListView*>("listView");
if(list)
{
list->setSelectionMode(QAbstractItemView::MultiSelection);
}
QTreeView* tree = fileDialog->findChild<QTreeView*>();
if(tree)
{
tree->setSelectionMode(QAbstractItemView::MultiSelection);
}
if(fileDialog->exec())
{
if(fileDialog->selectedFiles().size()>0)
{
int listsize=stringList.size();
for(int i=0;i<listsize;i++)
{
// get the name of the file
// check if the file is dicom
// upload if the file is dicom
// after uploading, get the pixel data of that file
// use the pixel data and make a icon out of it
//then insert the icon in an a QTablewView
}
}
}
//show the QtableView
}
能否请您指导我在上传部分运行时在哪里以及如何显示等待标志或符号?
谢谢
最佳答案
我认为您正在寻找 QProgressBar类(class)。该文档在下面明确说明。您需要设置最小值和最大值,它会为您完成这项工作。
The QProgressBar widget provides a horizontal or vertical progress bar.
A progress bar is used to give the user an indication of the progress of an operation and to reassure them that the application is still running.
The progress bar uses the concept of steps. You set it up by specifying the minimum and maximum possible step values, and it will display the percentage of steps that have been completed when you later give it the current step value. The percentage is calculated by dividing the progress (value() - minimum()) divided by maximum() - minimum().
You can specify the minimum and maximum number of steps with setMinimum() and setMaximum. The current number of steps is set with setValue(). The progress bar can be rewound to the beginning with reset().
If minimum and maximum both are set to 0, the bar shows a busy indicator instead of a percentage of steps. This is useful, for example, when using QNetworkAccessManager to download items when they are unable to determine the size of the item being downloaded.
我不认为可以根据问题提供更多详细信息,因为工作循环似乎在没有提供实际代码的情况下进行了注释,但是本文档应该以任何一种方式说明这一点。
请注意,我个人甚至会将工作循环移动到自己的工作线程中,如果它值得一个进度条的话。至于进度条,你可能会这样写:
QProgressBar bar(this);
bar.setRange(maximum, maximum);
bar.setValue(minimum);
bar.show();
关于c++ - 在 Qt 应用程序中加载文件时如何显示 "waiting"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20847518/
我是一名优秀的程序员,十分优秀!