简体   繁体   English

为什么我的自定义QHeaderView不允许排序

[英]Why won't my custom QHeaderView allow sorting

I implemented my own QHeaderView extending from QHeaderView. 我实现了自己从QHeaderView扩展的QHeaderView。

After I set sorting enabled on the QTableWidget that uses this view, I still cannot sort. 在我使用此视图的QTableWidget上启用排序后,我仍然无法排序。 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(). 唯一重载的方法是构造函数(强制水平)和sizeHint()。

I had to call 我不得不打电话

setClickable(true); 

in the constructor. 在构造函数中。 Now sorting is possible again. 现在可以再次排序。

For Qt5: 对于Qt5:

setSectionsClickable(true);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM