Scott Frankel wrote: > > Hello, > > What's the proper way to use QTreeWidget's itemAt() method? I'm > passing incrementing int values to it, yet it only returns the > tree's root item. eg: > > for ii in range(self.treeRowCount): > item = self.theTree.itemAt(0, ii) > > yields: > > ii: 0 > item: <PyQt4.QtGui.QTreeWidgetItem object at 0x59ed0> > text: rootItem > ii: 1 > item: <PyQt4.QtGui.QTreeWidgetItem object at 0x59ed0> > text: rootItem > ii: 2 > item: <PyQt4.QtGui.QTreeWidgetItem object at 0x59ed0> > text: rootItem > ii: 3 > item: <PyQt4.QtGui.QTreeWidgetItem object at 0x59ed0> > text: rootItem
The poblem is that itemAt() returns what is at the given view coordinate, not by row numbers. You're always getting the root item because your count is less than the pixel height of the root item. You could multiply the count by the height of a typical item, but that is probably not the cleanest way to do this. You could also use the itemBelow() method to cycle through the items. > (See attached for the full, simple code example.) > > Ultimately, I want to be able to identify a QTreeWidgetItem by the > results of its text() so that I can set the tree item's parent for > branch points. Than why not use QTreeWidget.findItems()? Doug. _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
