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().

有帮助吗?

解决方案

I had to call

setClickable(true); 

in the constructor. Now sorting is possible again.

For Qt5:

setSectionsClickable(true);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top