hakermania
24th August 2010, 19:32
This is the code:
void MainWindow::on_checkBox_clicked()
{
if ( ui->checkBox->isChecked() ){
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(write_random_image()));
timer->start(1000);
}
else
timer->stop();
}
actually, I wanna program , when the checkbox is clicked and checked, the timer must start, and if it is clicked and not checked the timer to stop..
The inly issue is that I get the error:
error: ‘timer’ was not declared in this scope (this goes to timer->stop();)
Even if I declare the creation of the timer at the constructor (in a try to use it globally in the program) I cannot call it because of the same error...
So, how can I fix this? :cool:
void MainWindow::on_checkBox_clicked()
{
if ( ui->checkBox->isChecked() ){
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(write_random_image()));
timer->start(1000);
}
else
timer->stop();
}
actually, I wanna program , when the checkbox is clicked and checked, the timer must start, and if it is clicked and not checked the timer to stop..
The inly issue is that I get the error:
error: ‘timer’ was not declared in this scope (this goes to timer->stop();)
Even if I declare the creation of the timer at the constructor (in a try to use it globally in the program) I cannot call it because of the same error...
So, how can I fix this? :cool: