在一个QTreeWidget中捕捉一个keyPressEvent而没有焦点 [英] Catching a keyPressEvent in a QTreeWidget with no focus
本文介绍了在一个QTreeWidget中捕捉一个keyPressEvent而没有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我假设你正在尝试做一些你真的不应该做的事情,但无论如何...
这是要走的路:
http://doc.qt.io/qt-4.8/qwidget.html#grabKeyboard
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!
解决方案
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
这篇关于在一个QTreeWidget中捕捉一个keyPressEvent而没有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文