[PyQt] Selecting several table items
Mads Ipsen
mpi at comxnet.dk
Thu Aug 20 11:47:47 BST 2009
Mads Ipsen wrote:
> Hi,
>
> Ho do I programmatically select several items in a QTableView? I can
> select one element by calling the method setCurrentIndex(), but that
> only selects a single item. I need to do this in order to write a
> proper unit test.
>
> Best regards,
>
> Mads
>
Hi,
Solved this one by doing somthing along the lines:
selection_model = table.selectionModel()
selection_model.clearSelection()
index = model.index(0,0)
selection_model.select(index, QtGui.QItemSelectionModel.Select)
index = model.index(1,0)
selection_model.select(index, QtGui.QItemSelectionModel.Select)
Sorry for bothering you with this,
Mads
--
+------------------------------------------------------------+
| Mads Ipsen, Scientific developer |
+------------------------------+-----------------------------+
| QuantumWise A/S | phone: +45-29716388 |
| Nørresøgade 27A | www: www.quantumwise.com |
| DK-1370 Copenhagen, Denmark | email: mpi at quantumwise.com |
+------------------------------+-----------------------------+
More information about the PyQt
mailing list