Qtimer timeout slot is executing in linux but not working in windows showing
QObject::startTimer: timers cannot be started from another thread
help me if anybody knows. Thanks in advance....
Qtimer timeout slot is executing in linux but not working in windows showing
QObject::startTimer: timers cannot be started from another thread
help me if anybody knows. Thanks in advance....
Create the timer in the run() method of the thread.
pradeepreddyg95 (24th September 2012)
hi wysota, I tried that method also same warning is coming but my confusion is same thing is working under ubuntu can u plz check the sample test code ...
Two things you are missing
1. Event loop is not being ececuted. (i.e exec(), this is required, else the thread will exit)
2. Timer should started from the parent thread , i.e the ctor() and run() functions execute in different thread context hence the object created on ctor() should be moved the the the thread, or other way is to create the timer in run() method (as wysota said)
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
pradeepreddyg95 (24th September 2012)
Thanks Santosh,
But in ubuntu i am using like this
void Thread::run()
{
while(1)
{
// some operations doing inside the loop
if(m_pProbeFailure[i].Value > m_nCuurrent_ADC_Value)
{
if(!m_pTimer[i].isActive())
m_pTimer[i].start();
}
}
}
like this iam using without calling exec() it working fine but in windows not working ... Plz solve my issue .... if any body ...
QTimer will works when you have have a event loop (i.e. call exec());, or other way is to explictily process the events by calling QCoreApplication:rocessEvents(), from the local while loop.
Qt Code:
void Thread::run() { while(1) { // some operations doing inside the loop if(m_pProbeFailure[i].Value > m_nCuurrent_ADC_Value) { if(!m_pTimer[i].isActive()) m_pTimer[i].start(); } } }To copy to clipboard, switch view to plain text mode
When you know how to do it then you may do it wrong.
When you don't know how to do it then it is not that you may do it wrong but you may not do it right.
pradeepreddyg95 (24th September 2012)
Bookmarks