[PyQt] QMap, QHash?

David Cortesi davecortesi at gmail.com
Fri Nov 16 18:34:12 GMT 2012


Working on implementing a List model using QAbstractListModel and
would like to implement (set)itemData which returns a QMap.

QMap seems to be Qt's version of a dict, a list of key:value pairs.
(QHash is apparently similar.) The point of itemData/setItemData is to
return or set the data for every property role of an item in one go,
instead of multiple calls to data/setData. (*)

Looking at the PyQt4 class dictionary I don't see QMap listed (nor
QHash). It would be rather cool if PyQt4 would support it with
automatic conversion to/from a dict, the way it happily converts
between u-strings and QStrings. But any support would be good.

Dave Cortesi

(*) I think itemData/setItemData is important because if your item has
one or more userData roles, this is the only way Qt would know they
exist to  include them when dragging an item. Or am I imagining this?
Drag/drop of model items in a view is a bit of a black hole to me.


More information about the PyQt mailing list