tags:

views:

51

answers:

2

I have a QToolBar on which there is a QToolButton. When QToolButton is pressed by mouse click then it perform some action. The same action is performed when space bar is pressed. I dont want the action to be fired on space bar press, but I want it on mouse click. How I can do this?

+2  A: 

Subclass QToolButton using inheritance and override QWidget::keyPressEvent(). There, check if the key you get is Qt::Key_Space and if it is, return and do nothing. if it isn't pass the event to QToolButton.

shoosh
A: 

Make sure you didn't accidentally assign 'Space' as the shortcut to the action associated with the QToolButton in question (check out Qt Creater's action editor).

codelogic