这个错误是因为你试图将一个std::string类型的返回值转换为QString类型的函数返回值,但是这两种类型不能直接转换。

解决方法是使用QString的构造函数将std::string类型的返回值转换为QString类型,例如:

std::string str = "Hello";
return QString::fromStdString(str);

或者使用QString的toStdString()函数将QString类型转换为std::string类型,例如:

QString str = "Hello";
return str.toStdString();
在QT中error no viable conversion from returned value of type stdstring aka basic_stringchar to function return type QString

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

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