Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top