Important: Please read the Qt Code of Conduct -

[SOLVED] QHeaderView ContextMenu: QTableView vs. QTreeView

  • Edit: Arrg, I had a stupid typo which overwrote the setHeader() method. I'm using PyQt where those magic things are possible. Well, once in a year you'd like to have a compiler as Python user. ;-)
    All good now.

    Hi everyone,

    I have created a custom QHeaderView to be able to choose the colums to be shown by right-clicking on the header. (I want to control the columns on the model level).

    I'm using a context menu an a set of toggleable actions to get the behavior.

    Using this header in a QTableView works perfectly (using setHorizontalHeader).

    Now when I use the same header in a QTreeView using setHeader, the header is shown but the contextmenu does not appear.

    Has anyone experienced similiar behavior or any comments on this topic? Shouldn't I use the setContextMenuPolicy "shortcut" on a QHeaderView?



  • Good :)

    Let's reply, so we can move it away from "Unanswered posts" :)


Log in to reply