[PyKDE] QAbstractItemView Question

Matt Chambers chambers at imageworks.com
Mon Nov 20 20:05:05 GMT 2006


Andreas Pakulat wrote:
> On 20.11.06 10:51:05, Matt Chambers wrote:
>   
>> Andreas Pakulat wrotee
>>     
>>>> I can detect if one of these elements is not in the new ElementTree, but, how 
>>>> do I get the info needed
>>>> to call beginRemoveRows( QModelIndex parent, int row, int col).  I can get 
>>>> the row,col no problem,
>>>> but how can I get the deleted items parent QModelIndex?
>>>>    
>>>>         
>>> Well, you have to have some mapping from Element back to a proper index,
>>> i.e. you need a way to get the index for an Element in the tree. Then
>>> you can call parent() on that index.
>>>       
>> I remember reading something about how the indexes are temporary.  I was under 
>> the impression
>> that they would go away and be re-created as needed?
>>     
>
> Yes and no. Yes the indexes are not meant to be "stored away", but they
> are cached by Qt's view classes.
>
> What I meant to say, if you implement a function that removes elements
> from your tree and doesn't take a QModelIndex to the parent of these
> indexes (like the removeRows() function does) then you need a way to
> calculate the index for this parent element. I guess the
> element-to-be-removed has a function to retrieve the parent, so you can
> calculate the row+col for that element too, if you can do it for the
> to-be-removed-element. Then to get the parent index of the parent
> element do the same. 
>
> Andreas
>   

Ahh, Ok, I got it thanks.  Working like a charm now.  Thanks!

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20061120/fdeacefe/attachment.html


More information about the PyQt mailing list