Wich is the fast and symple way for build a QString from a char or string value ?
I want to pass some string to a Qdialog that wants a QString ....
Thanks
Wich is the fast and symple way for build a QString from a char or string value ?
I want to pass some string to a Qdialog that wants a QString ....
Thanks
it works for me
Qt Code:
std::string ss = "test"; qDebug()<<aa;To copy to clipboard, switch view to plain text mode
As far as i know, that QString is going to be valid as long as the std::string will be. (it share data with that pointer returned by c_str() ) Please contradict me if i'm wrong!
So a better solution is the static member of QString fromStdString() for std::string
Or fromAscii(), fromLatin1() for char* string.
I want to use strings at Qmessagebox.
Exists a function at QmessageBox to convert string to Qstring (that is the parameter waited by Qmessabox) ?
I dont want to write no include if it is not neccesary.
Thanks Kabanek & Zlatomir
You don't have to include anything, both the methods i suggested are in the QString (static members of QString), if you didn't notice, in my previous post the functions names are links to documentation.
You can use it like this:
Qt Code:
std::string str = "Text"; what_ever->setText(inText);To copy to clipboard, switch view to plain text mode
Bookmarks