Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting keyboard events with pyqt

i converted recently from wxpython to pyqt and im still facing alot of problems since im still noob in pyqt

so is it possible to detected if user pressed (CTRL+key ) in pyqt ? and how ?



i've been trying to find an answer for this for 3 days . if you know website or a good place to learn pyqt, it will be highly appreciated

thanx in advance

like image 335
Moayyad Yaghi Avatar asked Jan 18 '26 00:01

Moayyad Yaghi


1 Answers

Add a QShortcut and listen to its activated() signal, then perform the action in the slot.

Or you could reimplement QWidget and define keyPressEvent to what you like. Check for the event parameter's modifiers() and key() to see if they match with what you want. This listens for shortcut keys when the QWidget has focus.

like image 197
szupie Avatar answered Jan 20 '26 15:01

szupie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!