Compilation error - 'QFuture' is not declared in this scope - Qt
-
Hello there,
I am trying to use QFuture and QtConcurrent classes in my application. I # included <QFuture> like this:
<QtCore/QFuture>
but when i compiled, got a compilation error. I could not event # include QtConcurrent.
Do I need to include something else in my .pro file to use both of these?
thanks
-
It should work. Did you use some special custom configure flags (if you have compiled Qt yourself)?
-
No nothing of that sort. Yeah, its strange. I am using Qt version 4.7.3 on QtCreator.
I just want to try something like
@void myclass::fun()
{}void myclass::init()
{
QFuture<void> future = QtConcurrent::run(fun);
future.waitForFinished();
}@therefore i want to include QFuture which documentation says should be found in @QtCore@ . Even after including QFuture, I am getting compilation error. QtConcurrent is not even getting included.
Please let me know if there is some issue with this.
-
I've never used that class. Here is what stackoverflow has to say on this: "link":http://stackoverflow.com/questions/16150961/qfuture-help-threading-c-qt.
So:
@
#include <QFuture>
#include <QtConcurrent/QtConcurrentRun>
@ -
[quote author="raj.qtdev" date="1382959691"]Thanks for putting a search but doesn't work for me. [/quote]
What exactly didn't work for you ? The compiler don't find the QFuture header or other linker error ? What sierdzio said is correct, so you should be fine including QFuture in that way. From what I see you try to run a class member function, in this case you need something like this:
@
QFuture<void> future = QtConcurrent::run(this, &myclass::run)
@ -
Perhaps you forgot to include this in your .pro file, but that is unlikely:
@
QT += core
@Since you have posted it in Mobile and Embedded, let me ask you this: even though you have not compiled Qt yourself, maybe you are aware of some special conditions your platform may be forcing? Maybe threading support is somehow throttled on that hardware?