您可以使用toStdString()函数将QString转换为std::string。示例代码如下:

QString qstr = "Hello, world!";
std::string str = qstr.toStdString();

注意:如果QString包含Unicode字符,toStdString()将使用UTF-8编码将其转换为std::string。如果需要使用其他编码,请使用QString::toUtf8()或QTextCodec。

Qstring转string

原文地址: https://www.cveoy.top/t/topic/fa9F 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录