Re: Cannot capture Key_Up
You have to set the focus policy and optionally focus proxy for your widgets appropriately.
Re: Cannot capture Key_Up
Thanks for the reply. I played around with the focus proxy and policy but still cannot get it to work.
Do I call MainWindow->setFocusProxy(Foo Widget)? and MainWindow->setFocusPolicy(Qt::NoFocus) ?
Leaving everything else alone on the Foo Widget. My Foo Widget children (GraphicsView/Scene) are still receiving the event correctly.
Re: Cannot capture Key_Up
What's the focus policy of the widget you want to capture the key in?
Re: Cannot capture Key_Up
Everything is set to default.
I'm assuming the MainWindow and centralwidget() configuration do something to intercept the Up/Down Keys.
I figured that's why I get the QEvent::ShortcutOverride event when I press the Up/Down key while sniffing the Foo widget's events.
Re: Cannot capture Key_Up
Quote:
Originally Posted by
xenome
Everything is set to default.
I'm assuming the MainWindow and centralwidget() configuration do something to intercept the Up/Down Keys.
Default focus policy of QWidget (and QMainWindow as well) is NoFocus.
Your widget simply doesn't have focus so it won't receive key events. If you want something to happen on a specific key combination you can register a shortcut for that combination - this is done via QShortcut (of course you still won't receive a keyPressEvent in your widget).
Re: Cannot capture Key_Up
Well I would think it has some focus as I receive all key events except the arrows.
Re: Cannot capture Key_Up
Please provide a minimal compilable example reproducing the problem.