擅长:python、mysql、java
<p>如果您希望<em>完全选中</em>的行数(即,当单击行标题时):</p>
<pre><code>len(tableWidget.selectionModel().selectedRows())
</code></pre>
<p>但如果您希望行中至少有一个单元格被选中:</p>
<pre><code>len(set(index.row() for index in tableWidget.selectedIndexes()))
</code></pre>