QTreeWidgetItem Parent

Python und das Qt-Toolkit, erstellen von GUIs mittels des Qt-Designers.
Antworten
andypsilon
User
Beiträge: 1
Registriert: Donnerstag 7. August 2008, 19:44

Hi!

I have the following problem:

I filled a QTreeWidget with data and now want the currently selected item back. But to process the data I also need the parents of it.

the .text() method works perfectly on the QTreeWidgetItem I created with .currentItem(), but as soon as I am creating a QTreeWidgetItem of the parent it says:

"NoneType Object does not have attribute text"

here is my code:


#works perfectly
currentShot = self.loadTree.currentItem()
print currentShot.text(0)


#throws described error
currentScene = currentShot.parent()
print currentScene.text(0)


If I print out the type of the QTreeWidgetItem's, they are both NoneType. Please can anybody help me? I'm lost!!!

thx,
andy

deutsche Antworten natürlich auch erwünscht :-)
lunar

"parent()" gibt "None" zurück, wenn das aktuelle Item kein Vater-Item hat. Wenn du etwas anderes erwartest, liegt der Fehler offensichtlich bei der Erzeugung der Items. Was genau da falsch ist, kann man mangels Code nicht sagen.

Poste ein kleines Snippet, dass den Fehler zeigt, und ich kann dir helfen. Mit den gegebenen Information ist das eher schwierig.
Antworten