开发者

qt: I would like to disable the key bindings automatically set for a QTreeView

I am using PyQt4 and a QTreeView (although this could just as easily apply to qt directly).

Right now there are default key bindings that control the expanding/collapsing of branches using the right and left arrows. Unfortunately, these bindings are not ideal and I would like to disable them. I have not been able to开发者_开发技巧 figure out how to do that. Does anyone know how to disable (or reassign) the default key bindings on a QTreeView?


There are two possible options for you: 1) Reimplement the keyPressEvent of QTreeView and check if the key pressed are either Qt::Key_Up or Qt::Key_Down.

2) You could install an eventFilter and check if the event is a QEvent::KeyPress and that the key matches either Qt::Key_Up or Qt::Key_Down.

I don't know PyQt so I can't give you code in Python, but I hope I have been clear enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜