PDA

View Full Version : Creating QString from std::sstream



Dennis_1
6th September 2007, 17:28
Hallo,

I have a problem convert stringstream to QString.
I know that the QString operator << is not overloaded in
qt4.
i know also that i have to use the std::string for QString
but i do not know how to do it exactly.
Please help me solving this problem.
i have update a code from qt3 to qt4.
the following code works in qt3 but not in qt3.

////////////////////////////
//Code that works in qt3:
stringstream ss;
ss << "FunctionCall" <<endl;
QString QStr = ss.str();
insertParagraph(QStr,0);
///////////////////////////

Question:
How can i update that code exactly to works with Qt4.
Thank you too much for your help.
Best Regards,

marcel
6th September 2007, 18:20
The solution:


stringstream ss;
ss << "FunctionCall" <<endl;
QString QStr = QString::fromStdString(ss.str());
insertParagraph(QStr,0);


You really should have created a new thread. This is not the appropriate place to start your thread.

Regards