[Qt-interest] Using QStringList (QT 4.4)
Malyushytsky, Alex
alex at wai.com
Tue Dec 9 21:15:44 CET 2008
Or if you want encoding to be done:
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QStringList lines;
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
lines.append (line);
}
>From QT documentation:
"QTextStream takes care of converting the 8-bit data stored on disk into a 16-bit Unicode QString. By default, it assumes that the user system's local 8-bit encoding is used (e.g., ISO 8859-1 for most of Europe; see QTextCodec::codecForLocale() for details). This can be changed using setCodec()."
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Rodrigo Delduca Batista
Sent: Tuesday, December 09, 2008 12:11 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Using QStringList (QT 4.4)
QStringList lines;
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
while (!file.atEnd()) {
lines.append(file.readLine())
}
or
QFile file("in.txt");
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QString str(file.readAll());
QStringList lines = str.split("\n");
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list