QTableWidget strange selection problems
-
Hello!
I'm using Python and PyQt4 and got a problem with selection of ranges in a QTableWidget. Suppose I have following table:
[name] [val1] [val2]
a 1 2
b ...
c ...
d ...
e ...I would now like to delete a selection of those rows (via a button). I tried several ways: table.selectedItems, table.selectionModel.selectedRows/Columns/Indexes/Selection. However every approach gives me wrong values when I selected multiple rows with Shift-key.
E.g. selectedRows is empty and selectedItems won't give me every item (but instead only a handful of items so only a few get deleted).Every help is appreciated!
-
selectedRows only returns the rows where all columns are selected. Maybe use it in conjunction with
@QAbstractItemView::setSelectionBehavior(QAbstractItemView::QAbstractItemView::SelectRows)@If that doesn't work, take a closer look at selectedIndexes, and maybe post some information about your input/output here. selectedIndexes will contain every single selected item, even multiple ones per row if you select complete rows.