What to use in place of the obsoleted qsort?
-
I was looking for a way to sort a QVector and came across this forum thread that uses qsort. I was able to leverage this in my own code and it works just fine but... My qt.512 documentation says that qsort is obsoleted.
What should I be using instead of qsort, now?
qSort(foo.begin(), foo.end(), [](const marker& a, const marker& b) { return a.intensity < b.intensity; });
-
The Qt is pretty darn good.
thanks again. -
Hi
The docs suggest using std::sort instead. -
OK, I just figured that since the original method used qSort and Qt usually provides a Qwhatever object/algorithm, there would be a newer qSuperSort or something like that. Reading further, I see there's a table of Q(algorithm)s that have been obsoleted and it includes their STL replacements.
thanks -
In the deprecation warning you even get a hint about what's the replacement:
https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/tools/qalgorithms.h?h=dev#n174"Use std::sort"
-
The Qt is pretty darn good.
thanks again.