There are couple of ways
1. Compare the string directly, character by character
or
2. Split into substrings, then convert eash substring to integer, then compare the integers.
or
3. Write a special function to convert into comparable numbers (weights)
or
4. Just remove the delimiters, then convert to integers, then compare
Example
while(version1.contains("."))
version1
= version1.
remove(QString("."));
while(version2.contains("."))
version2
= version2.
remove(QString("."));
if(version1.toUInt() < version2.toUInt())
{
...
}
QString version1 = "2.02.01";
QString version2 = "2.02.02";
while(version1.contains("."))
version1 = version1.remove(QString("."));
while(version2.contains("."))
version2 = version2.remove(QString("."));
if(version1.toUInt() < version2.toUInt())
{
...
}
To copy to clipboard, switch view to plain text mode
or
5. Maintain a map table to compare
Example
QMap<int, QString> map;
map.insert(1, "2.02.01");
map.insert(2, "2.02.02");
if(map.key(version1) < map.key(version2))
{
....
}
QString version1 = "2.02.01";
QString version2 = "2.02.02";
QMap<int, QString> map;
map.insert(1, "2.02.01");
map.insert(2, "2.02.02");
if(map.key(version1) < map.key(version2))
{
....
}
To copy to clipboard, switch view to plain text mode
Bookmarks