Ha oki, in this case use QTimer like you said.
You can connect the timeout signal of timer in released signal of button.
On the pressed event of the button you start the timer.
// Attribute in .h file
// In the constructor for example
connect(&this->_timer, SIGNAL(timeout()), this->ui->pushButton, SIGNAL(released()));
void MainWindow::on_pushButton_pressed()
{
_timer.start(1000);
}
void MainWindow::on_pushButton_released()
{
qDebug() << "Button pressed while 1000 ms";
_timer.stop();
}
// Attribute in .h file
QTimer _timer;
// In the constructor for example
connect(&this->_timer, SIGNAL(timeout()), this->ui->pushButton, SIGNAL(released()));
void MainWindow::on_pushButton_pressed()
{
_timer.start(1000);
}
void MainWindow::on_pushButton_released()
{
qDebug() << "Button pressed while 1000 ms";
_timer.stop();
}
To copy to clipboard, switch view to plain text mode
Bookmarks