I'm not totally sure what you're trying to do. If you're trying to read a file:
QFile file("/path/to/file.whatever");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text) {
// error message here
return;
end
while (!file.atEnd()) {
QString line = in.readLine();
// now, line will be a string of the whole line, if you're trying to read a CSV or something, you can split the string
QStringList list = line.split(",");
// process the line here
}
QFile
closes itself when it goes out of scope.
If you're trying to split a string based on the :
delimiter you have there, use:
QStringList list = line.split(":");
EDIT:
Now that you defined what you want to do (read a like like this "value:integer"), you can easily do that with QStringList. Example:
QString input = "value:1";
QStringList tokens = input.split(":");
int second = tokens.at(1).toInt();
Of course, you'll need to use your own error checking, but this is an example of what I think you're trying to do.