问题标签 [qbytearray]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
343 浏览

qstring - How to remove C2 A0 in QByteArray before converting to QString?

I have a QByteArray that has "C2 A0" in it that when converted to a QString makes "=C2=A0". I remove this "=C2=A0" and replace it with a space before I send it to be converted to a PDF. Problem is I always get the  in the resultant PDF. I have tried all kinds way to try and fix this. The file I send the pdf conversion service is verified not to have the "=C2=A0" in it yet it still appears. I need to remove this "C2 A0" from the QByteArray before converting to a QString. Is there a function where I can remove those bytes before the conversion to QString? I opened the file in a Mac hex editor and even with the "=C2=A0" removed the "C2 A0" is still there. I need to remove this bytes for proper conversion.

This answer isn't helping me: What is "=C2=A0" in MIME encoded, quoted-printable text?

0 投票
1 回答
1081 浏览

c++ - 将无符号的 short/int 转换为 char *

我有这样的功能

但是我收到访问冲突错误,似乎我不能做类似reinterpret_cast<char*>Portor的事情reinterpret_cast<char*>RequestId

0 投票
5 回答
3140 浏览

c++ - 将 char * 转换为 QString 并删除零

在我的应用程序中,我从本地(非 Unicode)字符集中的文件中读取字符串字段。该字段为 10 字节,如果字符串 < 10 字节,则余数用零填充。

所以我的问题 - 如何从字符串中删除尾随零?

PS我在调试时在“本地和表达式”窗口中看到零

0 投票
1 回答
534 浏览

c++ - 为什么不`unique_ptr` 降级为 `QByteArray*`?

我有以下代码:

我收到以下错误:

但为什么?当作为参数传递给采用指针的函数时,我认为unique_ptrshared_ptr自动降级为原始指针。如果不是,为什么不呢?如果他们(通常)这样做,为什么在这种情况下会失败QByteArray

我可以显式调用msg_buf_ptr.get(),但这似乎是不必要的。

0 投票
1 回答
647 浏览

linux - In Memory QFile with fwrite

Rather than going to the filesystem to save and read back a PGM image file, I want to do this in memory. Can I somehow use a QBuffer as an in memory QFile to bypass saving to the filesystem:

0 投票
0 回答
216 浏览

c++ - QByteArray 到“比特流”输出

我对以下代码有疑问。我正在尝试通过写入和读取数据的两个线程之间的共享布尔值(数据)传输 QByteArray,通过“同步”和“确认”布尔值进行通信 [通过电线模拟通信协议]。不幸的是,当我尝试将输出 QByteArray 转换为 bool 输出时,我得到一个“断言:”错误。以下是相关代码和输出。

控制台输出:

从调试消息中可以看出,循环适用于第一次迭代,但在第二位的输出上崩溃。我已经检查了 QByteArray 和位之间转换的其他代码源,据我所知语法是正确的。

谢谢你的帮助。

0 投票
1 回答
956 浏览

c++ - 使用 Qt 将二进制 std::stringstream 内容转换为 base64(并返回)

一旦base64编码,我想将一些犰狳矩阵保存在json文件中。这是我正在工作的不完整代码示例。我的问题是从 std::stringstream 转换为 QByteArray 并返回而不会丢失我的 stringstream 原始(确切)内容。

0 投票
2 回答
4473 浏览

c++ - QByteArray:如何在其中搜索一个字符

从 QByteArray 开始,我想在我的 QByteArray 中搜索 "\n" 字符,并将所有字符从开头连接到 "\n" 并将它们保存在 QString 中;之后,我将传递到下一个“\n”的以下字节并将它们保存到新的 QString

这将追加新行之前的所有字节;我的问题是如何评估 MyArray[counter],因为当计数器增加时我无法检查每个字节。

解决方案?

0 投票
1 回答
579 浏览

c++ - 如何使用 QtConcurrent 对 QByteArray 进行 qCompress?

我想编写一个小程序,使用 QByteArray 的 qCompress 压缩目录中的所有文件。

但是我想通过使用 QtConcurrent 在多线程环境中运行压缩。但我有一些问题。

这是我的代码:

问题是编译器给我一个错误

第一:没有匹配的函数调用过滤(&QByteArray,)。

第二:请求从 QList 转换为非标量类型 QByteArray。

所以,我的问题是,有可能做我想做的事吗?

提前致谢

0 投票
0 回答
535 浏览

qt - QByteArray 的内存布局是什么

我试图找到 QByteArray 的内存布局(因为我必须与一个以 QByteArray 作为参数的 DLL 交互)。从原始 QT 源中,我提取了以下内容:

(在这段代码中,我删除了所有函数,因为我只对数据布局感兴趣。)

所以我假设,内存布局如下:

这个对吗?我特别想知道“偏移”;通过查看代码,我的印象是,真实数据直接在偏移之后开始,并且是结构的一部分。真实数据似乎也可能位于“ArrayData”标头之前。

所以 'd' 可以指向以下布局之一:

这个对吗?

卡尔