I want to assign the value in QString to a const std::string
QString qfile("some value");
this is the const std::string variable
const std::string file
The code that I m using
file = qfile.toStdString();
above codes works fine for a normal std::string . But there is some problem because of the keyword ‘const’. How do I solve it ?
Don’t use the assignment operator to initialize the
std::stringobject but rather initialize the variable directly.That aside, please make sure that you’re aware of what encoding
QString::toStdString()uses; unlikeQString,std::stringis encoding-agnostic (it’s a string of bytes, not characters).