Search code examples
c++qtauthenticationtimerqtimer

Qt Login Timeout Using QTimer


I am trying to implement a login timeout when the username/password has been entered wrong too many time. But i am unable to do so. My code is below

ui->label->setText("Password entered wrong too many times, entered 10 minute cooldown period");
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(update())); 
    timer->start(6000);
    ui->pushButton->setVisible(false);
    if(!timer->isActive())
        ui->pushButton->setVisible(true);

Solution

  • Try this

    ui->pushButton->hide();
    QTimer::singleShot(5000, ui->pushButton, SLOT(show()));