I have to use the output of a function of a type const char*
and I need to convert it to QString
.
Note: inside that function, these are lines of code to return the const char*
char* ClassA::getData() const{
return const_cast<char *> (_foo.c_str());
}
where _foo
is std::string
.
I tried to use the following lines of code but always get empty string (actually not empty but contain only the new lines characters and neglect all other characters).
QString foo1 = QString(temp.getData());
QString foo2 = QString::fromLocal8Bit(temp.getData());
QString foo3 = QString(QLatin1String(temp.getData()));
QString foo4 = QString::fromAscii(temp.getData());
QString foo5 = QString::fromUtf8(temp.getData());