pravin4659
pravin4659

Reputation: 181

How to get table cell value from QTableWidget in pyside?

form_shift is form name

tblSession is QTableWidget object

shift_id=form_shift.tblSession.item(1,0).text()

Error:

AttributeError: 'NoneType' object has no attribute 'text'

Upvotes: 3

Views: 28764

Answers (1)

Weetu
Weetu

Reputation: 1773

This works just fine for me. Perhaps your table does not have an item at those coordinates?

table = QtGui.QTableWidget(5, 3, self)

for row in range(5):
  for col in range(3):
    table.setItem(row, col, QtGui.QTableWidgetItem("(%d, %d)" % (row, col)))


print("1,0: %s" % table.item(1, 0).text())

Upvotes: 7

Related Questions