我试图通过以下方法将QString转换为char*类型,但它们似乎不起作用.
//QLineEdit *line=new QLineEdit();{just to describe what is line here}
QString temp=line->text();
char *str=(char *)malloc(10);
QByteArray ba=temp.toLatin1();
strcpy(str,ba.data());
Run Code Online (Sandbox Code Playgroud)
你能用这种方法详细说明可能的缺陷,还是提供另一种方法?