[Qt-interest] QTexstStream to int and double
Stephen Jackson
spjackson42 at gmail.com
Thu Mar 19 13:01:05 CET 2009
On Thu, Mar 19, 2009 at 8:22 AM, Chris wrote:
[snip]
> I read a string from a file ex.
>
> 1 2 3 4.5 5.5 6.6
>
> and would like to put it in three different ints and doubles
> This is what I tried.
>
> int one, two, three;
> double oned, twod threed;
> QTextStream ssFile, line;
> ssFile.setDevice(&file);
> QString stringFile = ssFile.readLine();
> line.setString(&stringFile);
> line >> one >> two >> three >> oned >> twod >>threed;
>
> but it doesn't work. Is it possible to do something similar
In what way does it not work? Your code works for me, assuming that
the file has been opened and contains the text you indicate above. Is
the file being opened. What is the value of the string stringFile?
Regards,
Stephen Jackson
More information about the Qt-interest-old
mailing list