Home > other >  Qt how to realize the data in a read TXT file into an array, and will be one of the data showed on Q
Qt how to realize the data in a read TXT file into an array, and will be one of the data showed on Q

Time:09-26


The code can be read to realize digital, and words are but symbols of 0, how do I change?

QFile file (filename);

QVector Array;

If (file. Open (QIODevice: : ReadOnly))

{
QTextStream ts (& amp; The file);

while(! The file, atEnd ())
{

Float buf.
QStringList list=ts. ReadAll (). The split (QRegExp (" \ \ s + "));
While (li. HasNext ())
{
Buf=li. Next (). ToFloat ();
Array. Append (buf);
}
}
}
The UI - & gt; LineEdit - & gt; SetText (QString: : number (array [0]));