QTimer::singleShot(...) triggered from a QAction does not start!?
In my main window I've included an option to 'Check for updates' (available from a menu). Now, I'd prefer to start this updates check using a QTimer::singleShot(...) to prevent the menu from being "frozen" while the check for updates is ongoing and I've tried with the following:
Code:
void MainWindow::sendCheckForUpdates()
{
QTimer::singleShot(200,
this,
SLOT(checkForUpdates
()));
}
So, triggering the 'Check for updates' QAction in the QMenu starts 'sendCheckForUpdates()', which I would hope would only create and start this QTimer::singleShot(...) and then immediately (after say 200 msec:s) return, which would "release"/"unfreeze" the menu.
However, for some reason this does not work for me. I can see that I enter sendCheckForUpdates(), pass the QTimer::singleShot(...) line with no errors and then exits sendCheckForUpdates(), but then nothing happens. I never enter checkForUpdates(). If I try to have only a direct call to checkForUpdates() from within sendCheckForUpdates(), then it works (but the menu is frozen until the task is finished).
Any ideas?
I'm using Qt 4.4.3.
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Can you show the header file?
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Hi yogeshgokul,
I send you a personal message yesterday, with the header file. It's quite large, so not very suitable for posting here. Hope that's ok.
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
use to give the timer property singleShot(true) seperatly
like this
timer->setSingleShot(TRUE);
timer->start(200);
i think the problem is that u are not starting the timer but not sure ... any how try it once ..
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Quote:
Originally Posted by
wagmare
use to give the timer property singleShot(true) seperatly
like this
timer->setSingleShot(TRUE);
timer->start(200);
i think the problem is that u are not starting the timer but not sure ... any how try it once ..
No you doesn't need to start timer when using static member function QTimer::singleShot.
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
are you sure that checkForUpdates is slot?
take a look at console, maybe there are some error message or something else that can help you to solve the problem.
show us you header file.
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Quote:
Originally Posted by
dobedidoo
Hi yogeshgokul,
I send you a personal message yesterday, with the header file. It's quite large, so not very suitable for posting here. Hope that's ok.
Please attach it here only so everyone can see. :)
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Sorry, it's all my stupidity... I realized about two hours ago that (as 'spirit' pointed out later), I had missed to make checkForUpdates a SLOT. Which of course I thought I had... So, that's all there was - a simple misstake by me. :o
It all works just fine now.
Thanks for you replies!
Re: QTimer::singleShot(...) triggered from a QAction does not start!?
Quote:
Originally Posted by
dobedidoo
Sorry, it's all my stupidity... I realized about two hours ago that (as 'spirit' pointed out later), I had missed to make checkForUpdates a SLOT. Which of course I thought I had... So, that's all there was - a simple misstake by me. :o
It all works just fine now.Thanks for you replies!
Thats what we wanted to see your header :D
Anyways. :rolleyes: