Be default, QPushButton (like many other subclasses of QWidget) will have a default way of handling keyboard focus. In the case of buttons, arrow keys move the keyboard focus from one button to the next to facilitate navigating through the window and interacting with the widgets without a mouse.

As hank suggested in a comment, you can force the QPushButton to not accept keyboard focus by calling its setFocusPolicy(Qt::NoFocus), but that will only work in the particular case where the push buttons were the only ones in your QMainWindow that could steal focus. If your have other widgets in there (e.g. a QLineEdit), when the focus ends up there, the arrow keys will still not function right because the QLineEdit will grab those keys, and do nothing.

The more flexible way to solve your problem is to either install an event filter on each of your QMainWindow's child widgets, and have that event filter forward the arrow key events to the functions that rotate your cube (while letting everything else pass through to allow any other event to be processed by the appropriate widget).

Another solution would be to have your cube widget grab all keyboard events with QWidget::grabKeyboard(). That would ensure that every keyboard event gets sent to that widget, no matter where the keyboard focus is. When you want to let other widgets receive keyboard events, you will need to call QWidget::releaseKeyboard() to ungrab it.

How to forbid the use of arrow keys on the keyboard with pushbuttons in Qt
Today I saw a post on Facebook that had this pun:


  Clicked links turn purple because blue + "read" equals purple


Is there any specific reason why a link is blue and when it is clicked/read, it turns to purple?

Do these colors have any meaning?
