I am trying to use Qt 6 QPromise (as described in https://www.qt.io/blog/asynchronous-apis-in-qt-6):
QPromise<QByteArray> promise;
QFuture<QByteArray> future = promise.future();
promise.start();
qDebug() << "Pre timer";
QTimer::singleShot(2000, this, [p = std::move(promise)]()
{
qDebug() << "Timer triggered";
p.finish(); // error
});
But p.finish()
triggers a compilation error:
error C2662: 'void QPromise<QByteArray>::finish(void)': cannot convert 'this' pointer from 'const QPromise<QByteArray>' to 'QPromise<QByteArray> &'
Is the example code (from the blog entry) wrong, or did I miss something?
Regards,