PDA

View Full Version : QTimer - Why this is not working?



prasenjit
17th December 2009, 12:47
Hi,

I am using QT4 on Fedora 10. I am unable to run a timer event. Please help.
Attaching my code.

void MainWindow::test_func()
{
QMessageBox::information(this,"Test", "Testing Timer","Hi");
}

void MainWindow::on_actionSpatial_Connection_triggered( )
{
QTimer *timer = new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(test_fun c()));
timer->start(1000);
}

Basically I want to start a timer on a click event and the timer should call a function till the timer is stopped.

Thanks in advance...

spirit
17th December 2009, 12:58
are you sure that test_func is a slot?
show us header file.

wagmare
17th December 2009, 16:37
another thing is u are connecting the slot every time u click .. so first time it will call the slot test_func once and next click it will call it twice parallely and thrice ... keep on increasing the connect ..