0

I'm looking for a comparison function between QString that take in account digits. For example:

std::vector<QString> init { "test22", "test4", "test1", "test10", "test2" };

If I use basic QString::compare, it sorts the list like:

"test1", "test10", "test2", "test22", "test4"

But I'd like the list to be sorted like:

"test1", "test2", "test4", "test10", "test22"

In Win32 API, it corresponds to the function StrCmpLogicalW, but I'm looking for the equivalent with QString.

Thanks in advance

Tony
  • 1
  • Take a look at QCollator, specifically http://doc.qt.io/qt-5/qcollator.html#setNumericMode – xander Jun 23 '17 at 09:28
  • Thanks for the QCollator reference. It does the job. I think QString::compare() documentation should reference this class. – Tony Jun 23 '17 at 10:04

0 Answers0