from PyQt5.QtCore import Qt self.tree_widget.sortItems(0, Qt.DescendingOrder)#倒序 self.tree_widget.sortItems(0, Qt.AscendingOrder)#正序