高冢蕾娜,清穿之清音韵律,厦门休闲
最近在程序中遇到要把图片的二进制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
这个链接解释的很清楚
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
如何在没有core文件的情况下用dmesg+addr2line定位段错误
用QT制作3D点云显示器——QtDataVisualization
网友评论