keyPressEvent isn't called simultaneously.
-
wrote 29 days ago last edited by
I'm developping a RPG game.
When I push the right-key and push the up-key simultaneously, event loop stops.
Why?
bool MapScene::event(QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
qDebug() << "event";
}return QGraphicsScene::event(event);
}
I tried at the upper event, but the result was the same.
1.When I move a character to the right direction, naturally I push the right-key.
2.When I change the direction, for example, I push the down-key suddenly.
3.The event is not called.To call the event, I must release completely the key button once, and then push another button.
But I dislike such a way because it is not comfortable.
Please tell me how to solve this problem. -
wrote 27 days ago last edited by
The most likely answer is: buy a better keyboard! You might be expecting key jamming or ghosting (https://en.wikipedia.org/wiki/Key_rollover). There are online checks for key rollover.
-
wrote 21 days ago last edited by
Hi,
try use key handling in this way: https://stackoverflow.com/questions/23816380/using-multiple-keys-in-qt-c
I implement this in my simple qt game. Can check: https://github.com/Przemekkkth/top-down-shooter-qt
2/3