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

TP paratribulations at free.fr
Sun Apr 12 10:54:40 BST 2009


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.
Look at the following version which do not use any proxy, and works 
perfectly (when you click in the cells of the tree, the 
internalpointer() is displayed on standard output):

http://paratribulations.free.fr/help/python/withoutproxy.py

The only two modification compared to the previous file located at:

http://paratribulations.free.fr/help/python/simpleproxy.py

are:

1/ the two following lines have been commented:
#        self.proxyModel = CustomProxyModel()
#        self.proxyModel.setSourceModel( self.model )
Therefore I do not need "CustomProxyModel" class anymore, that is why I 
have commented this class too (5 lines commented):

#class CustomProxyModel( QSortFilterProxyModel ):
#
#    def filterAcceptsRow( self
#            , source_row
#            , source_parent_index ):
#
#        return True

So, no proxy is used now, that is why the file is named "withoutproxy.py".

2/ I have to set the model to the view, because the proxy is no more set 
to the view, so I have added the following line:

         self.view.setModel( self.model )

These are the only modifications made. Now it works perfectly. No 
problem with internalpointer().

I do not see any problem in the way I use the proxy.

Could this be a but in PyQt?

Thanks a lot for your help,

Julien



More information about the PyQt mailing list