Problem with qSort of QList<CustomType>
-
Hello, trying to sort QList <MyType> list. Doing this:
qSort(list.begin(),list.end(),sortFunc); .... bool sortFunc(const MyType1& mt1, const MyType2& mt2){ return false; }
So the first line of code above produce error:
error: C2064: term does not evaluate to a function taking 2 arguments.
What's the problem guys? I've already successfully sorted QStringList that way btw. Thanks in advance! -
One small thing to check: are you defining / declaring the
sortFunc
function before or after theqSort
invocation? ie if the code you've shown above is all within one file, and in the order you've shown, then try moving thesortFunc
function definition above theqSort
call in the file.Cheers.
-
Hello, trying to sort QList <MyType> list. Doing this:
qSort(list.begin(),list.end(),sortFunc); .... bool sortFunc(const MyType1& mt1, const MyType2& mt2){ return false; }
So the first line of code above produce error:
error: C2064: term does not evaluate to a function taking 2 arguments.
What's the problem guys? I've already successfully sorted QStringList that way btw. Thanks in advance!Let's see ... MSDN also provides comprehensive examples, by the way ...
-
Big thanks guys, next time i'll google better! Making the function static solved my problem. Thanks again for help guys!
-
One small thing to check: are you defining / declaring the
sortFunc
function before or after theqSort
invocation? ie if the code you've shown above is all within one file, and in the order you've shown, then try moving thesortFunc
function definition above theqSort
call in the file.Cheers.
@Paul-Colby said in Problem with qSort of QList<CustomType>:
One small thing to check: are you defining / declaring the
sortFunc
function before or after theqSort
invocation? ie if the code you've shown above is all within one file, and in the order you've shown, then try moving thesortFunc
function definition above theqSort
call in the file.Cheers.
You were absolutely right. Thanks!