MqttServer.cpp:125:43: No viable conversion from 'std::string' (aka 'basic_string<char>') to 'const QByteArray' qbytearray.h:181:5: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'const char *' for 1st argument qbytearray.h:189:12: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'QByteArray &&' for 1st argument qbytearray.h:463:12: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'QByteArrayDataPtr' for 1st argument qbytearray.h:524:20: candidate constructor not viable: no known conversion from 'std::string' (aka 'basic_string<char>') to 'const QByteArray &' for 1st argument qbytearray.h:405:67: passing argument to parameter 'hexEncoded' here
时间: 2023-10-14 08:06:00 浏览: 205
no viable conversion from type1 to type2 (解决方案).md
这个错误的意思是说,你正在尝试将一个`std::string`类型的变量转换为`QByteArray`类型,但是`QByteArray`没有一个可以接受`std::string`类型参数的构造函数。
要解决这个问题,你需要将`std::string`类型转换为`QByteArray`类型。你可以使用`QByteArray::fromStdString()`函数来实现这一点,例如:
```
std::string myString = "hello";
QByteArray myByteArray = QByteArray::fromStdString(myString);
```
这将把`myString`转换为一个`QByteArray`类型的变量`myByteArray`。你可以在你的代码中使用类似的方法来解决这个问题。
阅读全文