PDA

View Full Version : Quick ? about qSort(Container & container)



JimDaniel
15th December 2007, 04:13
My code looks something like this:


QSet<QString> mySet;
mySet.insert(someString);
...
qSort(&mySet);


But I'm getting this error:
'qSort' : cannot convert parameter 1 from 'QSet<T> *' to 'QSet<T> & ' with [T=QString] and [T=QString]

I think my logic/syntax is okay, so what is the problem?

marcel
15th December 2007, 07:13
qSort takes a reference to the container, not a pointer. So the correct call is:


qSort(mySet);

spud
15th December 2007, 11:20
You can't sort a QSet. use QMap<QString, bool> and the keys will be sorted on insertion. Or retrieve the keys and sort them:

QSet<QString> mySet;
...
QList<QString> values = mySet.values();
qSort(values);