Qstring转string
您可以使用toStdString()函数将QString转换为std::string。示例代码如下:
QString qstr = "Hello, world!";
std::string str = qstr.toStdString();
注意:如果QString包含Unicode字符,toStdString()将使用UTF-8编码将其转换为std::string。如果需要使用其他编码,请使用QString::toUtf8()或QTextCodec。
原文地址: https://www.cveoy.top/t/topic/fa9F 著作权归作者所有。请勿转载和采集!