| Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date | |
| All threads index page 1 | |
I am trying to read from a file but I am getting the whole line into my
QString were I only need just one column, I took a look to regex in QT
but before I go on and start experimenting I will like to know which
will be the best/nicer way to do this, after checking the documentation
for QTextStream I have not found exacly what I need, there is seek were
I can position at one line or another, but I need somehow to tell him
that when it gets to a space to stop and go to second line till end of file.
this below is giving me all the file not even the whole line:
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
while (!in.atEnd()) {
in >> texto >> endl;
}
--
[ signature omitted ]
On Wednesday 02 August 2006 05:40, rek2 wrote:
> I am trying to read from a file but I am getting the whole line into my
> QString were I only need just one column, I took a look to regex in QT
> but before I go on and start experimenting I will like to know which
> will be the best/nicer way to do this, after checking the documentation
> for QTextStream I have not found exacly what I need, there is seek were
> I can position at one line or another, but I need somehow to tell him
> that when it gets to a space to stop and go to second line till end of
> file.
Most text-stream implementations will give you whole lines.
With Qt you have several choices to split those lines afterwards:
a) the old fashioned way of DIY:
for(int i=0;i<str.length();i++){
dosomethingwith(str[i]);
}
b) splittig at certain characters or strings: QString::split
c) matching with regular expressions: QRegExp
Konrad
Attachment:
Attachment:
pgpCvFlmlhSxa.pgp
Description: PGP signature