You probably will want to take a look at QWidget::keyPressEvent():
Also maybe QObject::eventFilter():
If you look around the QObject and QWidget doc pages, you'll find an example or two of capturing keys.
One thing to note is that whatever widget is in focus will receive the event first (before its parent). Say you have a QWidget with a QFrame in it, and a QLineEdit inside the QFrame, and the QLineEdit has focus. When you press a key, the QLineEdit will receive the event first. It can then either eat the event (stop it, thus preventing the parent from seeing it) or pass it on to the parent.
Some widgets eat quite a few keystrokes, such as QTable, and the parent never sees them... this is where eventFilter can come in handy. EventFilter can intercept events being sent to another widget.
Hope that helps.