[PyQt] arbitrary instance attributes on qt widgets?

Erick Tryzelaar idadesub at users.sourceforge.net
Mon May 5 21:11:00 BST 2008


On Mon, May 5, 2008 at 12:17 PM, Wilbert Berendsen <wbsoft at xs4all.nl> wrote:
> Hi, Is this legal?
>
>  q = QListBoxText(listbox)
>  q.bla = 3
>
>  this sets a new attribute 'bla' to 3. I could use this to have the listboxitem
>  carry some other data.

Yes it is legal.

>  Or should I subclass QListBoxItem to add such an attribute?

Thats up to you :) One thing to be aware of is that if you access the
field directly instead of through setters that you can't use it as a
target for a slot.


More information about the PyQt mailing list