Obsolete Members for QtFuture

QtFuture 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。

函数

(since 6.1, deprecated in 6.6) QFuture<void> makeReadyFuture()
(since 6.1, deprecated in 6.6) QFuture<std::decay_t<T>> makeReadyFuture(T &&value)
(since 6.1, deprecated in 6.6) QFuture<T> makeReadyFuture(const QList<T> &values)

函数文档

[since 6.1, deprecated in 6.6] QFuture<void> QtFuture::makeReadyFuture()

自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用 `makeReadyVoidFuture()`。

创建并返回一个 voidQFuture 。此类QFuture 无法存储任何结果。可将其用于查询计算状态。返回的QFuture 将始终处于已完成状态。

auto f = QtFuture::makeReadyFuture();
...
const bool started = f.isStarted(); // started == true
const bool running = f.isRunning(); // running == false
const bool finished = f.isFinished(); // finished == true

应避免使用该方法,因为其重载定义不一致。从 Qt 6.10 起,在代码中使用它将引发编译器警告。

这是一个重载函数。

该函数在 Qt 6.1 中引入。

另请参阅 QFuture 、QFuture::isStarted()、QFuture::isRunning()、QFuture::isFinished()、QtFuture::makeReadyVoidFuture()、QtFuture::makeReadyValueFuture()、QtFuture::makeReadyRangeFuture() 以及QtFuture::makeExceptionalFuture()。

[since 6.1, deprecated in 6.6] template <typename T, typename = QtPrivate::EnableForNonVoid<T>> QFuture<std::decay_t<T>> QtFuture::makeReadyFuture(T &&value)

自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用makeReadyValueFuture()。

该函数创建并返回一个已包含结果value 的QFuture 。返回的QFuture 类型为std::decay_t<T>,其中T不为void。

auto f = QtFuture::makeReadyFuture(std::make_unique<int>(42));
...
const int result = *f.takeResult(); // result == 42

应避免使用该方法,因为其重载集不一致。从 Qt 6.10 开始,在代码中使用它将导致编译器警告。

这是一个重载函数。

该函数在 Qt 6.1 中引入。

另请参见 QFuture 、QtFuture::makeReadyVoidFuture()、QtFuture::makeReadyValueFuture()、QtFuture::makeReadyRangeFuture() 以及QtFuture::makeExceptionalFuture()。

[since 6.1, deprecated in 6.6] template <typename T> QFuture<T> QtFuture::makeReadyFuture(const QList<T> &values)

自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用 `makeReadyRangeFuture()`。

创建并返回一个QFuture ,该对象已通过values 设置了多个结果。

const QList<int> values { 1, 2, 3 };
auto f = QtFuture::makeReadyFuture(values);
...
const int count = f.resultCount(); // count == 3
const auto results = f.results(); // results == { 1, 2, 3 }

应避免使用该方法,因为其重载不一致。从 Qt 6.10 起,在代码中使用它将导致编译器警告。

这是一个重载函数。

该函数在 Qt 6.1 中引入。

另请参阅 QFuture 、QtFuture::makeReadyVoidFuture()、QtFuture::makeReadyValueFuture()、QtFuture::makeReadyRangeFuture() 和QtFuture::makeExceptionalFuture()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.