def indexTupleFromItem ( self , treeItem ) : # TODO: move to BaseTreeItem? if not treeItem : return ( QtCore . QModelIndex ( ) , QtCore . QModelIndex ( ) ) if not treeItem . parentItem : # TODO: only necessary because of childNumber? return ( QtCore . QModelIndex ( ) , QtCore . QModelIndex ( ) ) # Is there a bug in Qt in QStandardItemModel::indexFromItem? # It passes the parent in createIndex. TODO: investigate row = treeItem . childNumber ( ) return ( self . createIndex ( row , 0 , treeItem ) , self . createIndex ( row , self . columnCount ( ) - 1 , treeItem ) )
python how to get index of a tree item
Return ( first column model index last column model index ) tuple for a configTreeItem
def indexTupleFromItem(self, treeItem): # TODO: move to BaseTreeItem?
        """ Return (first column model index, last column model index) tuple for a configTreeItem
        """
        if not treeItem:
            return (QtCore.QModelIndex(), QtCore.QModelIndex())

        if not treeItem.parentItem: # TODO: only necessary because of childNumber?
            return (QtCore.QModelIndex(), QtCore.QModelIndex())

        # Is there a bug in Qt in QStandardItemModel::indexFromItem?
        # It passes the parent in createIndex. TODO: investigate

        row =  treeItem.childNumber()
        return (self.createIndex(row, 0, treeItem),
                self.createIndex(row, self.columnCount() - 1, treeItem))