Quote Originally Posted by jean View Post
Hi everybody,

I am sorry for posting what is probably a stupid question but I failed to find by myself the answer... sorting a Qlist with qSort() is tricky when the list only contains a single variable. But using a structure, it failed since the qSort() algorithm did not knows which field in the structure is to be sorted. Here is my code :

Qt Code:
  1. struct myData{
  2. QString namefile;
  3. int filesize;
  4. };
  5.  
  6. QList <myData> list;
  7. populatelist();
  8. ...
To copy to clipboard, switch view to plain text mode 

now how to sort list by namefile or filesize ?
I presume I need some pointers, but as newbie, I turn around it unsuccessfully. Thank you for any help.
follow:
myData md;
md.namefile="test";
md.filesize=100;
list.appand(md);