python - Getting Selected Rows Count in QTableWidget - PyQt -
in python plugin , i'm developing, need retrieve number of selected rows in qtablewidget . can loop through each row of qtablewidget , check them whether selected or not. instead, there straightforward way selected rows count of qtablewidget in pyqt ? something like: qtablewidget.selectedrowscount() if want number of rows fully selected (i.e. when clicking on row header): len(tablewidget.selectionmodel().selectedrows()) but if want rows have at least 1 cell selected : len(set(index.row() index in tablewidget.selectedindexes()))