'QFutureWatcher' does not name a type
Solved
General and Desktop
-
When I moved declaration of a QFutureWatcher object from a member function (where it was a local variable) to the header (in order to use its
finished()
signal), it started throwing the error in subject.a.cpp.cc was:
#include <QtCore> #include <QFutureWatcher> #include <QMessageBox> #include <QCoreApplication> #include <QtConcurrent> #include <QFileDialog> #include "a.h" a::fn() { auto lambda [x, y] (int& i) -> int {return 1;}; QFutureWatcher<void> fw; fw.setFuture(QtConcurrent::map(vec, lambda)); }
a.cpp.cc became:
#include <QtCore> #include <QFutureWatcher> #include <QMessageBox> #include <QCoreApplication> #include <QtConcurrent> #include <QFileDialog> #include "a.h" a::fn() { auto lambda [x, y] (int& i) -> int {return 1;}; fw.setFuture(QtConcurrent::map(vec, lambda)); }
a.h became:
class a : public QDialog { Q_OBJECT public: a(); virtual ~a(); private: QVector<int> vec; QRect rect; QGraphicsScene *scene; // added the next line: QFutureWatcher<void> fw; // -- error on this new line: 'QFutureWatcher' does not name a type };
I thought that as a.cpp.cc included the Qt headers before including a.h, QFutureWatcher should have been declared on the line where the error is being raised. What am I missing?