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.
{
if (val == LOCAL)
dir.setPath(BKGNDIMAGEPATHLOCAL);
else
dir.setPath(BACKIMAGEPATH);
fileFilter << "*.jpg" << "*.bmp";
dir.setNameFilters(fileFilter);
names << "user*" << "background*";
fileNames
= dir.
entryList(names,
QDir::Files);
fileNames.sort();
return fileNames;
}
QStringList getBackGroundFiles(int val)
{
QDir dir;
if (val == LOCAL)
dir.setPath(BKGNDIMAGEPATHLOCAL);
else
dir.setPath(BACKIMAGEPATH);
QStringList fileFilter,fileNames,names;
fileFilter << "*.jpg" << "*.bmp";
dir.setNameFilters(fileFilter);
names << "user*" << "background*";
fileNames = dir.entryList(names,QDir::Files);
fileNames.sort();
return fileNames;
}
To copy to clipboard, switch view to plain text mode
Bookmarks