ZBLOG

C:\Users\SFM301\Documents\mytimertest\main.cpp:33: error: invalid operands to binary expression ('const QString' and 'const std::string' (aka 'const basic_string'))

根据错误信息,你在C++代码中使用了一个QString对象和一个std::string对象进行了二元运算操作,但这两个类型之间没有定义对应的运算符重载。

要解决这个问题,你可以将std::string对象转换为QString对象或将QString对象转换为std::string对象,以便它们能够进行相应的操作。

如果你希望将std::string转换为QString,可以使用以下方式:

std::string stdStr = "Hello";
QString qstr = QString::fromStdString(stdStr);

如果你希望将 QString转换为 std::string, 可以使用以下方式:

QString qstr = "Hello";
std::string stdStr = qstr.toStdString();

请注意,在进行类型转换时要确保头文件 <QString><string> 被正确地包含到你的代码中。


内容由零声教学AI助手提供,问题来源于学员提问

本站部分文章来源于网络,版权归原作者所有,如有侵权请联系站长删除。
转载请注明出处:https://sdn.0voice.com/?id=3640

分享:
扫描分享到社交APP
上一篇
下一篇
发表列表
游客 游客
此处应有掌声~
评论列表

还没有评论,快来说点什么吧~

联系我们

在线咨询: 点击这里给我发消息

微信号:3007537140

上班时间: 10:30-22:30

关注我们
x

注册

已经有帐号?