I have a QList of Versions .. where Versions is a class and has two QStrings (text1 and text2)...
how can I sort this QList by text1?
Thanks
Printable View
I have a QList of Versions .. where Versions is a class and has two QStrings (text1 and text2)...
how can I sort this QList by text1?
Thanks
QStringList::sort () ? Also, qSort from <QtAlgorithms> would be helpful.
thx for the replies!
Can't really get it to work, may someone help me out?
Code:
Code:
QList<Version> allVersions; // adding some items through xml (irrelevant for this thread) // how do I sort this list now by the release date?
thanks!
Have you at least read the links that i gave you in my previous post?
Code:
class Version{ public: QString releaseDate; QString URL; }; bool VersionCompare(const Version& i, const Version& j) { return i.releaseDate < j.releaseDate; //what ever you consider necessary... for one Version to be lessThan other } int main() { QList<Version> list; list.append(Version("zz", "url")); list.append(Version("gg", "url")); list.append(Version("aa", "aa")); qSort(list.begin(), list.end(), VersionCompare); return 0; }
of course I did but I didn't get that I have to change the parameters in the compare function :)
It's all clear for me now!
Thanks :D