How to blink a pushbutton(Solved)



  • 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);
    }



  • 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);
    }



  • i use widget to solved it. I don't understand why i have always have to write workaround to solve simple problem.


  • Lifetime Qt Champion

    [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());
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.