Как сообщить о ProgressText из функции qtconcurrent :: run (или аналогичная) с qfuturewatcher?C++

Программы на C++. Форум разработчиков
Anonymous
Как сообщить о ProgressText из функции qtconcurrent :: run (или аналогичная) с qfuturewatcher?

Сообщение Anonymous »

If I launch some function for asynchronous execution using QtConcurrent::run, and am monitoring the returned future using a QFutureWatcher, what if anything can I do in that asynchronously executing function to communicate some progress text back which will result in the QFutureWatcher firing its progressTextChanged signal?
то есть, что я хочу сделать, это что -то < /em> нравится: < /p>

Код: Выделить всё

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 future=QConcurrent::run(fn);
watcher.setFuture(future);
However, big problem, the QtConcurrent::run documentation clearly states

Note that the QFuture returned by QtConcurrent::run() does not support
canceling, pausing, or progress Отчетность . Возвращенная Qfuture может быть использован только для запроса статуса работы /законченного статуса и значения return
функции. Должен ли я отказаться от qtconcurrent :: run ? Qfuture ? Оба? (И вернуться к QThread и подключено к очереди?)

Подробнее здесь: https://stackoverflow.com/questions/234 ... or-similar

Вернуться в «C++»