- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如果我使用 QtConcurrent::run
启动一些异步执行函数,并使用 QFutureWatcher
监控返回的 future ,如果我可以在异步执行函数中做些什么来传达一些进度文本,这将导致 QFutureWatcher
发射它的 progressTextChanged
信号?
即我想做的是:
void fn() {
???->setProgressText("Starting);
...
???->setProgressText("halfway");
...
???->setProgressText("done!");
}
QFutureWatcher watcher;
connect(&watcher, SIGNAL(progressTextChanged(const QString&)), &someGuiThing, SLOT(updateProgress(const QString&)));
connect(&watcher, SIGNAL(finished(), &someGuiThing, SLOT(doStuff()));
QFuture<void> future=QConcurrent::run(fn);
watcher.setFuture(future);
Note that the QFuture returned by QtConcurrent::run() does not support canceling, pausing, or progress reporting. The QFuture returned can only be used to query for the running/finished status and the return value of the function.
QtConcurrent::run
?
QFuture
?两个都? (然后回到
QThread
和排队连接?)
最佳答案
QtConcurrent 函数返回的 QFuture,如 QtConcurrent::mappedReduced()
具有由 progressValue()、progressMinimum()、progressMaximum() 和 progressText() 函数提供的进度信息。不像 QtConcurrent::run()
它不会自动提供这样的东西。QtConcurrent::run()
不自动提供进度信息,如 QtConcurrent::mappedReduced()
.但是您可以使用信号拥有自己的进度报告机制。我不认为有任何其他方式是直接的。
关于c++ - 如何从 QtConcurrent::run 函数(或类似函数)向 QFutureWatcher 传达 progressText?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23438044/
我想在安装过程中显示我的自定义操作的进度文本。我在 WiX Progress Text for a Custom Action 中实现了代码但它不起作用。 显示所有其他文本(例如文件副本),正确填充
如果我使用 QtConcurrent::run 启动一些异步执行函数,并使用 QFutureWatcher 监控返回的 future ,如果我可以在异步执行函数中做些什么来传达一些进度文本,这将导致
我是一名优秀的程序员,十分优秀!