아미(아름다운미소)

PyQt5 : QHeaderView의 헤더를 클릭하면 QTableView를 정렬하는 방법 본문

랭귀지/PYTHON

PyQt5 : QHeaderView의 헤더를 클릭하면 QTableView를 정렬하는 방법

유키공 2018. 12. 8. 16:11

QHeaderView의 헤더를 클릭하면 QTableView를 정렬하는 방법입니다.

다음 과 같은 함수를 DataFrame사용하면 올바르게 정렬됩니다.
def sort(self, Ncol, order):
    """Sort table by given column number."""
    self.layoutAboutToBeChanged.emit()
    self.data = self.data.sort_values(self.headers[Ncol],
                                      ascending=order == Qt.AscendingOrder)
    self.layoutChanged.emit()
Comments