简体   繁体   中英

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

I wanted to convert a QPixmap to std::vector . For now I am doing the following

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

However I donot know how to convert QbyteArray to std::vector<unsigned char>

any suggestions ?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM