Keyboard shortcut assigned to a push button

Hello,

I’ve seen examples of how to assign keyboard shortcuts in the forum and the script repository. I was wondering if there is a quick way to simply assign a keyboard shortcut to an existing push button (without necessarily calling a function). The idea is to use the shortcut as an alternative to clicking the push button.

For example, in Qt for Python it is possible to assign a shortcut to a button using button.setShortcut(). Unless I made an error somewhere, I was not able to replicate this in a custom slicer module.

# Example with PySide6
from PySide6.QtGui import QKeySequence

###...other lines here...
# Set the shortcut to Ctrl+B (for example)
self.button.setShortcut(QKeySequence("Ctrl+B"))

Thanks!