Hi,
I have a QStringList in which I am trying to sort before I insert into a QComboBox.
The names are "background1.jpg, background2.jpg... background15.jpg. or user1..userX.jpg
The sort applies the order as such:
background1.jpg
background10.jpg
background11.jpg..
background2.jpg..etc

I need the list sorted in this order.
background1.jpg
background2.jpg
background3.jpg
...background10.jpg
background11.jpg

I have read the QMap but I cannot understand how to apply the sorting method I am looking for. Can anyone suggest a method?

Here is my code, it will either get my background files from a USB drive (for copying) or from the local filesystem for selecting in a combobox.
Qt Code:
  1. QStringList getBackGroundFiles(int val)
  2. {
  3. QDir dir;
  4. if (val == LOCAL)
  5. dir.setPath(BKGNDIMAGEPATHLOCAL);
  6. else
  7. dir.setPath(BACKIMAGEPATH);
  8. QStringList fileFilter,fileNames,names;
  9. fileFilter << "*.jpg" << "*.bmp";
  10. dir.setNameFilters(fileFilter);
  11. names << "user*" << "background*";
  12. fileNames = dir.entryList(names,QDir::Files);
  13. fileNames.sort();
  14. return fileNames;
  15. }
To copy to clipboard, switch view to plain text mode