There are many ways to do it. QString::toInt() can convert a string to a number. You can use QString::lastIndexOf() or similar to find position of the last whitespace in the line and treat the rest as the number. Or you can use a regular expression.
QRegExp rx
("#####START TEXT (\d+)");
while(file.canReadLine()){
if(rx.exactMatch(line)){
qDebug() << "STARTING TAG WITH ID" << rx.cap(1);
}
}
QRegExp rx("#####START TEXT (\d+)");
while(file.canReadLine()){
QString line = file.readLine();
if(rx.exactMatch(line)){
qDebug() << "STARTING TAG WITH ID" << rx.cap(1);
}
}
To copy to clipboard, switch view to plain text mode
Besides, you know how many characters the "preamble" has (16), so you can read the id directly from the position it should start on.
int id = line.mid(16).toInt();
int id = line.mid(16).toInt();
To copy to clipboard, switch view to plain text mode
Bookmarks