PyQt + shortcut for launching a button

How to configure keyboard shortcuts to press specific buttons in a PyQT application? For example: Ctrl+ 1click one button, and Ctrl+ 2to click another?

+3
source share
1 answer

Use QtGui.QShortcut : you create it with QKeySequence, and it emits a signal activated()when you enter this key sequence while the shortcut-parent widget has focus (of course, you connect these signals to the slots you have selected, including the "buttons).

+7
source

Source: https://habr.com/ru/post/1727998/


All Articles