[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Using __hash__ functions for custom classes
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2020-03-31 8:29:09
Message-ID: 067b467badee1b5b62e663de567f6ae4 () riverbankcomputing ! com
[Download RAW message or body]

On 31/03/2020 01:58, Stephen Knox wrote:
> Noob question here.
> 
> Is there any guidance on how to implement __hash__ functions for custom
> classes. Should they be generated automatically if there is a qHash
> function?
> 
> I am trying specifically to debug this issue:
> https://github.com/qgis/QGIS/issues/29225, which is caused by the
> QgsActionScope class not having a hash function. There is an __eq__
> function but no __hash__ function.
> 
> Code is at
> https://github.com/qgis/QGIS/blob/master/src/core/qgsactionscope.cpp,
> https://github.com/qgis/QGIS/blob/master/src/core/qgsactionscope.h and
> https://github.com/qgis/QGIS/blob/master/python/core/auto_generated/qgsactionscope.sip.in
> .
> 
> I have tried implementing a special-method in the sip.in file but can't
> seem to get the syntax right, and I am unsure whether this is necessary 
> or
> not.

You have to implement __hash__ yourself where you need it. There are 
plenty of examples in the PyQt .sip files.

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic