I am currently attempting to get a QTimer
to work and emit the appropriate signals when running in a separate Thread. I'm not sure what I should do in order to get the timeout()
signal to be emitted.
When I try using QFuture
and QFutureWatcher
they do not ever throw their finished()
signal as this thread never really ends, it just keeps looping.
I've looked at a number of other questions 1, 2, 3, 4, 5 to no avail.
This is what I currently have. Any advice would be greatly appreciated!
Foo.cpp
Foo::Foo() {
...
mcTimerForSpoilers = new QTimer(this);
connect(mcTimerForSpoilers, SIGNAL(timeout()), this, SLOT(queueDownloadOfSpoilerFile()), Qt::QueuedConnection);
QtConcurrent::run(this, &Foo::manageSpoilerTimer);
}
void Foo::manageSpoilerTimer() {
...
mcTimerForSpoilers->setInterval(5000); // 5 seconds
mcTimerForSpoilers->start();
}
void Foo::queueDownloadOfSpoilerFile() {
...
std::cerr << "Queue Download" << std::endl;
manageSpoilerTimer(); // Restart the timer
}