The item you're getting is indeed from the proxy model. You'll have to get
it, and then map it to the original.
http://qt-project.org/doc/qt-4.8/qabstractproxymodel.html#mapToSource


On 13 June 2014 11:40, David Martinez <[email protected]> wrote:

> Hi,
>
> I've been experimenting with Model View Programming and so far, I've been
> able to create a QTreeView which displays the data of my custom model
> (Inheriting from 'QtCore.QAbstractItemModel'). I created my own custom kind
> of object to use within the model (as I'm storing some data about the items
> being stored). I use the 'internalPointer' method in the model to get a
> reference to my original object if I need it. I also have a
> 'QtGui.QSortFilterProxyModel' between the view and the model which allows
> me to filter and sort the results.
>
> Everything seems to be working as expected but I'm struggling to get
> something working. I want to be able to right click an item on the treeView
> and get a popup menu which contains information about the specific item.
>
> That means that I'm interested on the 'QModelI' value in the 'Model' for
> the element selected in the 'QTreeView' so I can retrieve the original node
> using 'internalPointer' and get the information that I need.
>
> I'm not sure how to get the index in the original 'model' though. I have
> tried to use the 'indexAt(QPos)' method of the treeView but I guess that
> this is returning the index that it has within the view and not the model.
>
> I'm not sure if I would need something like a 'selectionModel'. I started
> to try that but I think that it would give me the index of the
> 'QSortFilterProxyMode' instead of the one of 'QAbstractItemModel'.
>
> Is there anything obvious that I'm missing?
>
>
> Thanks in advance,
>
>
>
> --
> David Martinez - Technical Animator
>
> Email: [email protected]
> Website: http://www.elusiveideas.com
>
>
>  --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpwXVJS7Ko5_XUf3cTRML%2BpXBjt8h1Pm2EXz03HQaobR3Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAMLeNpwXVJS7Ko5_XUf3cTRML%2BpXBjt8h1Pm2EXz03HQaobR3Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*Marcus Ottosson*
[email protected]

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAFRtmODaD%2BOOc5mXJR9swZMdkE9KX0%2Bt7v23dkH91FeampiSkQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to