Issue
I have a subclass of QTableWiget. I can sort this table by click on horizontal header. And now I also want to emit a signal when the table is sorted, so I overload method sortItems of baseclass:
def sortItems(self, col, order):
super(CustomTable, self).sortItems(col, order) # CustomTable is my subclass
self.sort_items.emit(col)
After that, I have a method to process that sort_items signal, like print the column, but it did not work, did not print anything. (I set sortingEnable for subclass... too)
I also try another way. This is horizontalHeader sectionClicked signal, it works, but sometimes the window is not focus, the horizontal header is clicked, but the table is not sorted.
So, my question is does QTableWidget call sortItems when it sorting? And how to fix that, make emit sort_items signal work?
Thanks for any help and sorry for my bad English.
Solution
(1) No, and it wouldn't help anyway - sortItems
isn't virtual, so overriding it will have no effect.
(2) You could try conecting to the sortIndicatorChanged signal of the horizontal header.
Answered By - ekhumoro
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.