title: Convert const char* to QString
body: <p>I have to use the output of a function of a type <code>const char*</code> and I need to convert it to <code>QString</code>.</p>
  
  <p>Note: inside that function, these are lines of code to return the <code>const char*</code></p>
  
  <pre><code>char* ClassA::getData() const{
      return const_cast&lt;char *&gt; (_foo.c_str());
  }
  </code></pre>
  
  <p>where <code>_foo</code> is <code>std::string</code>.</p>
  
  <p>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).</p>
  
  <pre><code>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());
  </code></pre>