kiker99
3rd July 2006, 18:09
Hello,
i don't quite understand how QTextStream works together with QStrings. I've got this code:
QString s;
QTextStream ts(&s);
ts<<11<<" Freunde";
std::cout<<"1."<<ts.readAll().toStdString()<<'\n'<<"2."<<s.toStdString();
That produces this output:
1.11 Freunde
Why doesn't QTextStream write to the String, as intended? I would be happy with this behaviour, too, but why do I have to specify a string as an argument with the constructor? Is there a function that needs to be called? I didn't find one and in the examples it works without one - but the examples work with devices rather than QStrings.
Thanks.
i don't quite understand how QTextStream works together with QStrings. I've got this code:
QString s;
QTextStream ts(&s);
ts<<11<<" Freunde";
std::cout<<"1."<<ts.readAll().toStdString()<<'\n'<<"2."<<s.toStdString();
That produces this output:
1.11 Freunde
Why doesn't QTextStream write to the String, as intended? I would be happy with this behaviour, too, but why do I have to specify a string as an argument with the constructor? Is there a function that needs to be called? I didn't find one and in the examples it works without one - but the examples work with devices rather than QStrings.
Thanks.