On Tue, Dec 6, 2016 at 8:31 PM Ruchit Bhatt <ruchitinnewfush...@gmail.com>
wrote:

> I tried
>
> print self.proxyModel.rowCount()  #works fine but its not  recursive
>
>
I'm not sure what you expect the results to be. What kind of recursive
value do you expect? A total of all row count of all hierarchies in the
tree?
Model.rowCount() gives you the row count of the root of the model, which if
you are getting 1 means an invisible root item.

If you wanted to print the first tier of visible items, it would be
something like this:

model = tree.model()
root = model.index(0,0)for row in xrange(model.rowCount(root)):
    print model.index(row, 0, root).data()

​

Now, if you were to do this recursively or iteratively, then you could
print every row, down every child, until you decide to stop. Is that what
you are after? A recursive or iterative solution to walking the tree model?


> and
>
>  print self.proxyModel.rowCount(parent=QtCore.QModelIndex())    #Gives
> error
>
>
The parent argument would be an index that you get from the model in the
first place. Like in my previous example, you could start with the
invisible root item of the tree:

root = model.index(0,0)

​

Now you can pass this parent in order to get the row count of it, and then
continue to change the parent and either do depth first or breadth first
traversal through the tree model.


>
> how you are able to use parent outside class ??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/cb3a247a-df03-4a17-826a-987085855d3e%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/cb3a247a-df03-4a17-826a-987085855d3e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3boc5XUhST11sjiqDi237D43Q0c9%2BURTJxb%2BMOpdobgA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to