How to blink a pushbutton(Solved)
-
wrote on 1 Nov 2014, 20:51 last edited by
Hi
Anyone can comment why the code below cannot blink a pushbutton
while(5<6)
connect(&timer1,SIGNAL(timeout()),this,SLOT(setvisible));
connect(&timer2,SIGNAL(timeout()),this,SLOT(setinvisible));
}
void setvisible()
{
ui->pb->setvisible(true);
}voi setinvisible()
{
ui->pb2->setvisible(false);
} -
wrote on 1 Nov 2014, 20:51 last edited by
while(5<6)
connect(&timer1,SIGNAL(),this,SLOT (setvisible());
connect(&timer2,SIGNAL(),this,SLOT (setinvisible());
}
void setvisible()
{
ui->pb->setvisible(true);
}voi setinvisible()
{
ui->pb2->setvisible(false);
} -
wrote on 2 Nov 2014, 03:05 last edited by
i use widget to solved it. I don't understand why i have always have to write workaround to solve simple problem.
-
[quote author="houmingc" date="1414875115"]
@
while(5<6) < infinite loop ?
connect(&timer1,SIGNAL(),this,SLOT (setvisible()); <- why two timers ?
connect(&timer2,SIGNAL(),this,SLOT (setinvisible()); <- are the timers class variables ?
}
void setvisible()
{
ui->pb->setvisible(true);
}voi setinvisible()
{
ui->pb2->setvisible(false);
}@
[/quote]Simpler version
@
connect(timer,SIGNAL(),this,SLOT (toggleVisibility());
}
void toggleVisibility()
{
ui->pb->setVisible(!ui-->pb->isVisible());
}
@
3/4