Quantcast

Get a list of selected rows in a QTableWidget

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Get a list of selected rows in a QTableWidget

starglider.dev
Hi,
how can I get a list of all selected rows in a QTableWidget.
I try to play with selectedIndexes() but don't know how to convert in rows index.

Thank you in advance for your help.


_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get a list of selected rows in a QTableWidget

Russell Valentine
rows=[]
for idx in self.table.selectedIndexes()
        rows.append(idx.row())

starglider develop wrote:

> Hi,
> how can I get a list of all selected rows in a QTableWidget.
> I try to play with selectedIndexes() but don't know how to convert in rows
> index.
>
> Thank you in advance for your help.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> PyQt mailing list    [hidden email]
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt

_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get a list of selected rows in a QTableWidget

Andreas Pakulat
On 04.03.10 17:52:01, Russell Valentine wrote:
> rows=[]
> for idx in self.table.selectedIndexes()
> rows.append(idx.row())

Better would be using self.table.selectionModel().selectedRows(), the
above can add duplicates to your list of rows if multiple columns are
selected.

Andreas

--
Accent on helpful side of your nature.  Drain the moat.
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Get a list of selected rows in a QTableWidget

starglider.dev
Thank you Andreas for your suggestion.


On 5 March 2010 07:22, Andreas Pakulat <[hidden email]> wrote:
On 04.03.10 17:52:01, Russell Valentine wrote:
> rows=[]
> for idx in self.table.selectedIndexes()
>       rows.append(idx.row())

Better would be using self.table.selectionModel().selectedRows(), the
above can add duplicates to your list of rows if multiple columns are
selected.

Andreas

--
Accent on helpful side of your nature.  Drain the moat.
_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [hidden email]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Loading...