Hi all,

I see that qSort is deprecated in newer versions of Qt. I can also see that std::sort is intended to replace it. But I can't figure out how to use std::sort to sort a QList with a custom compare function. With qSort you could supply your own comparison function to sort however you wanted. I don't see how to do this with std::sort. Do you have to subclass and provide a operator< overload? I'd rather just define a comparison function, is this possible?

Thanks,

Josh

bool variantLessThan(const QVariant &v1, const QVariant &v2)
{
   return v1.toString() < v2.toString();
}

qSort(fieldsList.begin(), fieldsList.end(), variantLessThan);
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to