tableWidget에 텍스트를 채우는 동안 모든 행에 self.ui.tableWidget.resizeRowToContents
을 사용했습니다. 그 이후 : self.ui.tableWidget.setSortingEnabled(1)
, 정렬은 예상대로 작동하지만 행의 내용은 더 이상 크기가 조정되지 않습니다. 실제로는 이전 높이가 유지됩니다.Python-QTableWidget : 헤더를 정렬 할 때 신호를 잡는 방법
name name v name v
--------- --------- ---------
text2 text1line1 text1line1
--------- after sort is clicked: --------- expected: text1line2
text1line1 text1line3
text1line2 text2 ---------
text1line3 text2
--------- --------- ---------
내 생각은 클릭 헤더에 정렬 할 때 신호를 잡아, 모든 행을 self.ui.tableWidget.resizeRowToContents
다시 이동하는 것입니다. 신호를 잡는 방법? 당신이 채울으로 당신은 또한 당신의 행에 대한 크기 조정 모드를 설정하려고 할 수 있습니다 http://doc.qt.nokia.com/4.7-snapshot/qheaderview.html
header = self.ui.tableWidget.horizontalHeader()
header.sortIndicatorChanged.connect(self.fixRowSizes)
:
감사합니다, 즉 내가 찾던 정확히입니다. – Aleksandar