select more than one row in table widget using pyqt
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.
Re: select more than one row in table widget using pyqt
Have you tried to use the selection model direct via QAbstractItemView::selectionModel()?
Re: select more than one row in table widget using pyqt
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
Re: select more than one row in table widget using pyqt
Quote:
Originally Posted by
parkourpenner
So I will read more about, maybe I will get it ;)
Code:
tableWidget
->selectionModel
()->select
(tableWidget
->model
()->index
(0,
0),
QItemSelectionModel::SelectCurrent|QItemSelectionModel
::Rows);
tableWidget
->selectionModel
()->select
(tableWidget
->model
()->index
(1,
1),
QItemSelectionModel::Select|QItemSelectionModel
::Rows);
to select row 1 and 2...