Qt:将QPixmap保存到std::vector<无符号字符>-或者将QByteArray转换为std::

Qt: save QPixmap to std::vector<unsigned char> - or convert QByteArray to std::vector<unsigned char>

本文关键字:std gt QByteArray 转换 字符 或者 lt 保存 QPixmap vector Qt      更新时间:2023-10-16

我想将QPixmap转换为std::vector。现在我正在做以下

     QPixmap pixmap;
     QByteArray bytes;
     QBuffer buffer(&bytes);
     buffer.open(QIODevice::WriteOnly);
     pixmap.save(&buffer, "JPG");

但是我不知道如何将QbyteArray转换为std::vector<unsigned char>

有什么建议吗?

仅供记录,因为用户@Lol4t0没有这么做:

 std::vector<unsigned char> c(bytes.constData(), bytes.constData() + bytes.size());