self.filter_edit = QLineEdit()
vbox = QVBoxLayout() vbox.addWidget(self.filter_edit) self.setup_connections()
def setup_connections(self): self.tableWidget_2.horizontalHeader().sectionClicked.connect(self.sort_table) self.filter_edit.textChanged.connect(self.filter_table) def sort_table(self,column): self.tableWidget_2.sortItems(column,Qt.SortOrder.AscendingOrder) def filter_table(self,filter_text): for row in range(self.tableWidget_2.rowCount()): print(self.tableWidget_2.rowCount()) match = False for col in range(self.tableWidget_2.columnCount()): item = self.tableWidget_2.item(row, col) if filter_text.lower() in item.text().lower(): match = True break self.tableWidget_2.setRowHidden(row, not match)