QString to char* conversion

Well, the Qt FAQ says:

int main(int argc, char **argv)
{
 QApplication app(argc, argv);
  QString str1 = "Test";
  QByteArray ba = str1.toLocal8Bit();
  const char *c_str2 = ba.data();
  printf("str2: %s", c_str2);
  return app.exec();
}

So perhaps you’re having other problems. How exactly doesn’t this work?

Leave a Comment