2

i have an editable row in my tablewidget. The values are from a .txt. My intension is it to change some Values in the widget, and then make a new .txt with the changed Values. but i dont know how to "extract" the changed Values from the widget.

with

item=self.model.item(1,1)
iteml.append(item)
print(iteml)

I only get:

[<PyQt4.QtGui.QStandardItem object at 0x02DD2A98>]

But I don't want the memory address but the Value. Any Ideas?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Hubschr
  • 1,285
  • 6
  • 18
  • 35

2 Answers2

3

Adding on top of Mailerdaimon: If you want the string as a python string instead of a PyQt4.QtCore.QString object, you can simply use

item=self.model.item(1,1)
thestring = str(item.text())

(Sorry, I would have posted a comment, but I'm not allowed since I don't have 50 rep.)

phfaist
  • 253
  • 4
  • 6
0

Use:

item=self.model.item(1,1)
item.text()

to get the Text Value of the QTableWidgetItem

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46
  • if i use `print(item.text())` i get the Value, but if I add "item.text())" to a list, with `list.append(item.text())` i get "[PyQt4.QtCore.QString(u'Value')"... why? – Hubschr Nov 25 '13 at 11:06
  • if you add the item (not the string) to a list `print list[i].text()` should work – Mailerdaimon Nov 25 '13 at 12:12