擅长:python、mysql、java
<p>如果要从选定行中的项目中获取文本,可以尝试以下操作:</p>
<pre><code> indexes = tablewidget.selectionModel().selectedRows(column)
for index in sorted(indexes):
row = index.row()
rowtext = []
for column in range(tablewidget.columnCount()):
rowtext.append(tablewidget.item(row, column).text())
print(rowtext)
</code></pre>
<p>但是请注意,<a href="http://qt-project.org/doc/qt-4.8/qitemselectionmodel.html#selectedRows" rel="nofollow">selectedRows</a>只获取选择了<em>所有</em>项的行。在</p>