PyQt + shortcut to trigger a button

旧巷老猫 提交于 2019-12-12 14:31:49

问题


How do I configure keyboard shortcuts to click specific buttons in a PyQT app? Eg: Ctrl + 1 to click one button while Ctrl + 2 to click the other?


回答1:


Use QtGui.QShortcut: you build it with a QKeySequence, and it emits the activated() signal when that key sequence is typed while the shortcut's parent widget has focus (of course, you connect those signals to slots of your choosing, including buttons').



来源:https://stackoverflow.com/questions/2039241/pyqt-shortcut-to-trigger-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!