PDA

View Full Version : select more than one row in table widget using pyqt



parkourpenner
15th July 2009, 16:28
I'm some kind of desperate.
I use a table widget in pyqt to list some items for the user. The user is able to select some filenames in a filedialog and add them to the table by using a button. I also want the user to be able to change some properties of the items he just added.
Therefor I want the items, which the user added, to be selected. No Problem, if the user just add one item, but I really don't get it, how to select more than one row in the table by code. (the adding of the items to the table no problem too)
Just using qttable.selectRow(..) more than once lead to a error called
"Exception RuntimeError: 'maximum recursion depth exceeded in __subclasscheck__' in <type 'exceptions.RuntimeError'> ignored"
I tried to change the selectionMode to extendedselection or multi, but that obviously did not work out too.
I read some stuff about using itemmodel and itemselectionmodel, but I really didn't get it how to use these functions and even not, if I can reach my goal with using them.

Lykurg
15th July 2009, 18:44
Have you tried to use the selection model direct via QAbstractItemView::selectionModel()?

parkourpenner
15th July 2009, 18:50
thats a function i have found, but wasn't really sure about how to use and functionality.
But that's at least a hint.
So I will read more about, maybe I will get it ;)
Thanks

Lykurg
15th July 2009, 19:20
So I will read more about, maybe I will get it ;)

tableWidget->selectionModel()->select(tableWidget->model()->index(0,0), QItemSelectionModel::SelectCurrent|QItemSelectionM odel::Rows);
tableWidget->selectionModel()->select(tableWidget->model()->index(1,1), QItemSelectionModel::Select|QItemSelectionModel::R ows);
to select row 1 and 2...