如何从 BYTE* 转换为 QString?

发布于 2024-09-18 05:33:13 字数 151 浏览 5 评论 0原文

我有一个 DATA_BLOB 结构,但我需要将其转换为QString。我该怎么做?

I have a DATA_BLOB structure but I need to convert it to QString. How can I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

嗫嚅 2024-09-25 05:33:13

您可以使用 QString 构造函数 带有 QByteArray 参数。
您也可以将 构造函数const 一起使用char* 参数也

希望有帮助

You can use the QString constructor with a QByteArray parameter.
You can use too the constructor with the const char* parameter too

Hope that helps

走野 2024-09-25 05:33:13
BYTE* myByteBlob; 
int myByteBlobSize;

// Get the blob, find out the size.
// ...

QString myString( QByteArray( myByteBlob, myByteBlobSize));
BYTE* myByteBlob; 
int myByteBlobSize;

// Get the blob, find out the size.
// ...

QString myString( QByteArray( myByteBlob, myByteBlobSize));
偏爱你一生 2024-09-25 05:33:13
   BYTE* pu8_RawData = (BYTE*)i_RawData.parray->pvData;
   DWORD u32_RawLen  =        i_RawData.parray->rgsabound[0].cElements;

   qDebug() << QString(QByteArray((const char*) pu8_RawData, (int)u32_RawLen));
   BYTE* pu8_RawData = (BYTE*)i_RawData.parray->pvData;
   DWORD u32_RawLen  =        i_RawData.parray->rgsabound[0].cElements;

   qDebug() << QString(QByteArray((const char*) pu8_RawData, (int)u32_RawLen));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文