Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove multiple rows from QTable Widget?

I want to remove multiple rows which are selected in the QTableWidget . can anyone have any ideas ?

like image 738
joki Avatar asked Nov 05 '22 07:11

joki


1 Answers

You can remove multiple items at once, The tips, is begin delete the rows from the bottom. i'm sorry im not a VS2008 developer, but this solution can be easy convert to VS2008 code. Here the Python code. Sorry for the late response :)

# Delete the selected mytable lines
deleteRows(self.mytable.selectionModel().selectedRows())

# DeleteRows function
def deleteRows(self, rows):
        # Get all row index
        indexes = []
        for row in rows:
            indexes.append(row.row())

        # Reverse sort rows indexes
        indexes = sorted(indexes, reverse=True)

        # Delete rows
        for rowidx in indexes:
            self.mytable.removeRow(rowidx)
like image 63
Bruno Adelé Avatar answered Nov 15 '22 07:11

Bruno Adelé