bikalpa
28th September 2012, 12:07
i am using qtimer for traffic light change in junction. i have created four state and each state run for some second.
But after sometime it hang and when i see task manager the memory consumed by that application rises.
i have created four state n each state is called from previous state.please tell me where i am wrong..
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(state1() ))
void Dialog::state1()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state2() ));
timer->start(2000);
}
void Dialog::state2()
{
timer->stop();
//code to draw traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state3() ));
timer->start(2000);
}
void Dialog::state3()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state4() ));
timer->start(2000);
}
void Dialog::state4()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state1() ));
timer->start(2000);
}
But after sometime it hang and when i see task manager the memory consumed by that application rises.
i have created four state n each state is called from previous state.please tell me where i am wrong..
timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(state1() ))
void Dialog::state1()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state2() ));
timer->start(2000);
}
void Dialog::state2()
{
timer->stop();
//code to draw traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state3() ));
timer->start(2000);
}
void Dialog::state3()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state4() ));
timer->start(2000);
}
void Dialog::state4()
{
timer->stop();
//code to draw appropriate traffic light
connect(timer,SIGNAL(timeout()),this,SLOT(state1() ));
timer->start(2000);
}