If I understand you correctly you want the last element of the list (after the last ":
"). You can do the following:
QRegExp tagExp(":");
QStringList firstList = str.split(tagExp);
// Get the last string from list:
// "34 t"
// "513 l"
// "21 o"
// "0x0147 [FBI] Miscellaneous No. "
// "89f2aad996ae4a5c961a 123 532af2" <<-- this is the last element in list
QString requiredPart = firstList.takeLast();
The function takeLast
gets the last string and returns it and also removes it from the list. If you don't want to remove the last element from the list you can do something like:
QString requiredPart = firstList.value(firstList.length() - 1);
or
QString requiredPart = firstList.at(firstList.length() - 1);
or
QString requiredPart = firstList[firstList.length() - 1];
But the first option is the safest as it covers you for "out of bounds" issues better.
You can also use:
requiredPart = requiredPart.trimmed();
to remove any spaces at the start / end. Or go further and use:
requiredPart = requiredPart.simplified();
To remove excess white-space within the string. You probably don't need this.