[Qt-interest] Simple qSort() question
michael.goddard at nokia.com
michael.goddard at nokia.com
Thu Jan 13 08:12:57 CET 2011
> I'm sorry, but I think I must really be missing something here. That's
> what I'd like to achieve (I already have a lessThan function written),
> but
> don't see how to do that. As soon as I sort my first QStringList, the
> QList<int> no longer points to the members of that QStringList...
> That's
> the problem, that I can't figure out how to sort a list AND indexing
> information together (at least easily). I guess I could create my own
> class and reimplement all the necessary functions, but was trying to
> avoid
> that if there was a simpler way. Thanks again.
You just sort your QList<int> instead, and have your lessThan(a,b) do something like {return stringListA[a] < stringList[b];}. If you then need to reorder all of the string lists at least you have the mapping.
Cheers,
MichaelG
More information about the Qt-interest-old
mailing list