I have a QDialog
with a QDialogButtonBox
. The OK and Cancel buttons are active. Occasionally I disable or hide the OK button based on the state of my dialog. It seems, no matter what I do, the Enter key always activates the OK button. I really DON'T want this to happen. I have tried:
- Setting default and autoDefault properties to false every time I show/hide/enable/disable/whatever the button
- installing an event filter on the OK button to intercept key events (pressed and released) for return, enter and space
- Setting the focus policy on the button to NoFocus
And with all combinations of those things above, the Enter key still accepts the dialog. Does anyone have any clue how to block this? It seems like I should be able to block something as simple as this?