views:

202

answers:

2

hello
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

+2  A: 

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

Or you could eimplement 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.

szupie
+1  A: 

As for websites to learn, this is the official documentation - it takes some getting used to, but is quite helpful once you get the lay of the land (so to speak). This tutorial is what I walked through to get the initial idea, before discovering the documentation.

Good luck!

P.S. You might also look at QAction, if you are trying to map your Ctrl+X to an action that may also be performed by a menu or toolbar button... It incorporates a shortcut along with icons and/or text in a very convenient package. Just FYI.

Rini