当前位置: 移动技术网 > IT编程>开发语言>C/C++ > string转QBytearray

string转QBytearray

2019年02月23日  | 移动技术网IT编程  | 我要评论

高冢蕾娜,清穿之清音韵律,厦门休闲

最近在程序中遇到要把图片的二进制string存成图片到本地,其实就是写文件

                                        structcamerainfo tmpcamerainfo;
                                        string strdata = tmpcalibratereq.images(i).data();
                                        string strcameraname = tmpcalibratereq.images(i).camera_name();
                                        qfile file;
                                        qstring strimgpath = qapp->applicationdirpath() + "/" + qstring::fromstdstring(strcameraname) + ".jpg";
                                        file.setfilename(strimgpath);
                                        if(file.open(qiodevice::writeonly))
                                        {
                                            //qbytearray tmpbytearray = qstring::fromstdstring(strdata).tolatin1();这种写法是错误的
                           qbytearray tmpbytearray(strdata.c_str(), strdata.length());//这才是正确的 file.write(tmpbytearray); file.close(); }

https://cloud.tencent.com/developer/ask/32018

这个链接解释的很清楚

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网