Search code examples
pythonfocuspyqtkeypress

Catching a keyPressEvent in a QTreeWidget with no focus


So I desired to remove the ugly dotted border on my QTreeWidget by setting NoFocus on the focus policy. Now I need to catch keyPressEvents, but the focus policy is preventing that. Any ideas how one might circumvent this catch 22 so that I can catch a delete key press for easy item deletion? Thanks in advance!


Solution

  • I assume you are trying to do something that you really shouldn't, but anyways …

    This is the way to go: http://doc.qt.io/qt-4.8/qwidget.html#grabKeyboard