相关疑难解决方法(0)

QString to char*转换

我试图通过以下方法将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)

你能用这种方法详细说明可能的缺陷,还是提供另一种方法?

c++ qstring qt qtcore

83
推荐指数
6
解决办法
16万
查看次数

标签 统计

c++ ×1

qstring ×1

qt ×1

qtcore ×1