PDA

View Full Version : QSet<QVariant> is supported ?



nikhilqt
4th February 2010, 05:52
QList<QVariant> list;
QSet<QVariant> varSet;
varSet = list.toSet();

Is this not possible? Am getting error If i do so saying this overload is not supported.

franz
4th February 2010, 07:14
QSet is based on QHash. QHash doesn't know how to hash a QVariant. You'll have to find a different solution for what you want, or if the variants are all of the same type, convert them to the type and make a set out of that.

Aside from that you could tell QHash how to hash a QVariant, by providing a qHash() function for QVariants.