Alternative way:
std::string s = "This is an STL string";
QString qs = QString::fromAscii(s.data(), s.size());
This has the advantage of not using .c_str()
which might cause the std::string
to copy itself in case there is no place to add the '\0'
at the end.