Search code examples
qtsortingqheaderview

Why won't my custom QHeaderView allow sorting


I implemented my own QHeaderView extending from QHeaderView.

After I set sorting enabled on the QTableWidget that uses this view, I still cannot sort. For what it is wroth, the table is initially sorted by the first column. If I do not set the horizontal header to my custom class, sorting is performed.

The only overloaded methods are the constructor (forces horizontal) and sizeHint().


Solution

  • I had to call

    setClickable(true); 
    

    in the constructor. Now sorting is possible again.

    For Qt5:

    setSectionsClickable(true);