- Subclassing QCheckBox and reimplementing the keyPressEvent() to catch the enter key. Doesn’t work, apparently the key event doesn’t get through the QWidgetAction class.
- Subclassing QWidgetAction and reimplementing the event() function. Doesn’t work either.
- Connecting the QWidgetAction triggered() signal to the inherited toggle() slot from QCheckBox. It works partially, but not as intended. When connecting all actions to their respective checkboxes and pressing enter on whichever crate, only the last crate is modified. I will investigate further.
Also, I don't know if this can be done but ideally pressing enter would only select or unselect the crate, not pop the menu. However, the latter happens because it's the default behaviour for QMenu when an action is triggered. As mentioned in point 2, I tried reimplementing the event() function in the QWidgetAction but it doesn't work.
So, here's the things I've tried:
- Subclassing QCheckBox and reimplementing the keyPressEvent() to catch the enter key. Doesn’t work, apparently the key event doesn’t get through the QWidgetAction class.
- Subclassing QWidgetAction and reimplementing the event() function. Doesn’t work either.
- Connecting the QWidgetAction triggered() signal to the inherited toggle() slot from QCheckBox. It works partially, but not as intended. When connecting all actions to their respective checkboxes and pressing enter on whichever crate, only the last crate is modified. I will investigate further.
Also, I don't know if this can be done but ideally pressing enter would only select or unselect the crate, not pop the menu. However, the latter happens because it's the default behaviour for QMenu when an action is triggered. As mentioned in point 2, I tried reimplementing the event() function in the QWidgetAction but it doesn't work.