Catching a keyPressEvent in a QTreeWidget with no focus

巧了我就是萌 提交于 2019-12-11 17:29:46

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/9423391/catching-a-keypressevent-in-a-qtreewidget-with-no-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!