Is there support for the negation operator using PythonQt::TypeSlots?
Dynamic Python binding for Qt Applications
Brought to you by:
florianlink,
marcusbarann
Hey folks, is there a way to support negation for my custom types, e.g.,
something = -my_type_instance
? I have in-place subtraction implemented using the correct flags and overriding iadd in my C++ wrapper for my class, but it seems like negation is a bit different.I think you need a negate slot and the type enum is Negate.
On Mon 16. Nov 2020 at 02:24, Flower lady fancyflowerlady@users.sourceforge.net wrote:
I looked this up, you actually need an overloaded
__sub__
slot without second object, which returns a negated object. This is due to the code generator and c++, where negation and subtraction is the same -operatorWonderful, thanks Florian! Any tips on where to go to look up these sorts of things? The documentation is a bit sparse. I can also dig into the code, but there is a LOT of code, and it's hard to tell where the meat of the C++ to Python conversion is happening.
I ask because I am trying to get a slot working for getitem, but no dice for me, so I might be using the wrong types. I attempted with :