0

I am using QT on Windows 10.

I am using a QDialog where I want to push the QPushButtons also with the return key. However, I want that the user has to push the return key and release it again. Long pressing the return key should work only once and not several times.

I checked the keyPressEvent and the keyReleaseEvent, but unfortunately when I do a long press with the return key, I get continuously keyReleaseEvent and keyPressEvent.

Any ideas, how I can detect if the return key is long pressed or how I can I disable the long pressed functionality?

Quizard
  • 71
  • 1
  • 5

1 Answers1

0

you can start the timer in keyPressEvent and in keyReleaseEvent read elapsed

QElapsedTimer mTimer;
keyPressEvent ()
{
  .....
  mTimer.start();
  .....
}
keyReleaseEvent ()
{
  .....
  int mMilliseconds = mTimer.elapsed();
  .....
}

and you can set the label for a long press

Vahagn Avagyan
  • 750
  • 4
  • 16