[PySide] subclassing dict to connect to QT signal
Frank Rueter | OHUfx
frank at ohufx.com
Sun Oct 22 09:19:37 CEST 2017
Thanks, that is exactly what I have done for now, but I thought
subclassing dict was more to the point in context of what I was trying
to achieve. But I'm happy either way.
Thanks for the advice!
On 10/22/2017 08:03 PM, Jorge Javier Araya Navarro wrote:
> In my opinion, instead of trying to use inheritance, you may want to use composition.
> Thus, you create a class based on `QtCore.QObject` and make it to keep the dictionary you want to
> manipulate as an attribute of the class.
> El domingo 22 de octubre del 2017 a las 0621 horas, Frank Rueter escribió:
>> Hi all,
>> I am trying to subclass dict in order to connect it to a QT signal which
>> will create a value in a predetermined key.
>> This is what I got:
>> class CustomDict(dict):
>> '''Container for a simple version dictionary to be able to connect
>> a signal to it'''
>> def setData(self, data):
>> self['my_custom_data'] = data
>> However, when I try to connect the setData method I get this:
>> TypeError: unhashable type: 'CustomDict'
>> Can somebody help me understand what's going on?
> 👋 Pax et bonum.
> Jorge Javier Araya Navarro
More information about the PySide