Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Arrow Key navigation QTreeView



  • Hello,
    I want to navigate in a QTreeView like it was a normal TableView.
    Therefore Key_up and Key_down events should trigger the selection to go to the same column of the previous or following row in the tree (like when the view is fully expanded ant the tree-structure is ignored).
    However the default event will do some strange things depending on if the current row has children it will trigger expand or collapse instead of moving the cursor.

    One way to achieve the behavior I want would be to reimplement the keyPressEvent and then manipulate the currentIndex of the model, however this is kind of complicated.
    Is there an easier way to achieve the desired behavior?


Log in to reply