Hubschr
Hubschr

Reputation: 1335

How to get a Value from a Qtable

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?

Upvotes: 2

Views: 2705

Answers (2)

phfaist
phfaist

Reputation: 253

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.)

Upvotes: 3

Mailerdaimon
Mailerdaimon

Reputation: 6080

Use:

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

to get the Text Value of the QTableWidgetItem

Upvotes: 0

Related Questions