[英]Convert gpointer to QByteArray in QT
How can I convert gpointer
bytes (FT_BYTES) to QByteArray
in Qt?如何在 Qt 中将
gpointer
字节 (FT_BYTES) 转换为QByteArray
? Point:观点:
a) gpointer
is a type like void*
in glib Linux package. a)
gpointer
是 glib Linux package 中的void*
类型。
b) A hex dump like a0 23 5c
which is stored as gpointer
and I like to convert it to hex in QByteArray
format b) 像
a0 23 5c
这样的十六进制转储,它存储为gpointer
,我喜欢将其转换为QByteArray
格式的十六进制
QByteArray createQBAfromGP(gpointer gp, int byteCount)
{
return QByteArray::fromRawData((char *)gp, byteCount);
}
Be aware that the bytes are not copied.请注意,字节不会被复制。 The
QByteArray
is merely a view into the original memory. QByteArray
只是原始 memory 的一个视图。 If you want them copied, you can如果你想复制它们,你可以
QByteArray convertToQBA(gpointer gp, int byteCount)
{
return QByteArray().append(QByteArray::fromRawData((char *)gp, byteCount));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.