Let me first show you a piece of code:
void PaddleItem::keyPressEvent(QKeyEvent *e)
{
qDebug() << timer.elapsed()-lastTime;
lastTime = timer.elapsed();
if(velocityX < maxAbsoulteVelocity && velocityX > -maxAbsoulteVelocity)
{
if(e->key() == Qt::Key_Left)
{
velocityX -= 15;
qDebug() << "LEFT " << velocityX;
}
if(e->key() == Qt::Key_Right)
{
velocityX += 15;
qDebug() << "RIGHT " << velocityX;
}
}
I measured the interval between the first and the second occurance of QKeyEvent after pressing the key - I found it is 500 ms. Further intervals are only about 33 ms. So, once again to be clear - I am pressing left arrow and it goes like that: Event - 500 ms - Event - ~33 ms - Event - ~33 ms - Event etc. It is quite problematic for me since I want my paddle to move smoothly - and this lag makes it impossible. How can I deal with that?