[PyQt] Re: segfault when using a proxy and SIGNAL( "clicked(QModelIndex)" )

Andreas Pakulat apaku at gmx.de
Mon Apr 13 08:54:41 BST 2009

On 12.04.09 11:54:40, TP wrote:
> Demetrius Cassidy a écrit :
>> Why do you need access to the QModelIndex internal pointer? It sounds like
>> you are trying to access a null pointer, causing a crash.
>> Looking at the signature, ptr is some sort of id or extra data associated
>> with the index, which you probably need to add yourself when creating an
>> index.
>> QModelIndex QAbstractItemModel::createIndex ( int row, int column, void *
>> ptr = 0 ) const   [protected]
> Accessing the internal pointer does not hurt when I do not use a proxy,  
> as I am going to show it to you.

The reason you get a segfault when using a proxy is quite simply that
you're trying to access something which doesn't exist. The index you get
in cellClicked is not an index of your custom model, its an index of the
proxy model, which doesn't have an internal pointer (or maybe it does,
but its not what you expect). Whenever you get an index from a view or
selection model and you're using proxy models, you first have to convert
from the proxy index into a source index via mapTosource() from


Don't you feel more like you do now than you did when you came in?

More information about the PyQt mailing list