Unexpected behaviour when setSortingEnabled(1) is called
我有一个
当我运行图形用户界面时,如果不单击任何列的标题来排序表,则会出现问题,然后执行以下操作:
1 2 3 | tableWidget.setSortingEnabled(0); // check/uncheck some checkable items here tableWidget.setSortingEnabled(1); |
在这种情况下,重写的
请帮帮我,打电话给
从DOCS(C++ QT,但适用):
sortingEnabled : bool
This property holds whether sorting is enabled.
If this property is true, sorting is enabled for the table. If this
property is false, sorting is not enabled. The default value is false.Note:. Setting the property to true with setSortingEnabled()
immediately triggers a call to sortByColumn() with the current sort
section and order.
号
如果您检查qheaderview的文档(小部件查询该文档以了解要排序的列),您可以阅读:
int QHeaderView::sortIndicatorSection () const
Returns the logical index of the section that has a sort indicator. By
default this is section 0.See also setSortIndicator(), sortIndicatorOrder(), and
setSortIndicatorShown().
号
还有:
Qt::SortOrder QHeaderView::sortIndicatorOrder () const
Returns the order for the sort indicator. If no section has a sort
indicator the return value of this function is undefined.
号
所以你应该小心点