QT使用QDataStream輸出二進位制檔案多四個位元組
阿新 • • 發佈:2019-01-24
使用如下QDataStream方式輸出二進位制檔案,檔案頭部多四個位元組,代表檔案大小,不管怎麼都去不了;//寫二進位制檔案QFile file("F:/1.rgb");if(!file.open(QIODevice::WriteOnly)){QMessageBox::critical(this,"Warning", "Can't open file for writing",QMessageBox::Ok);return;}QDataStream out(&file);out.setVersion(QDataStream::Qt_4_0);out << data;file.close();最終捨棄,使用write方式寫入二進位制檔案,輸出正常//寫二進位制檔案QFile file("F:/1.rgb" );if(!file.open(QIODevice::WriteOnly)){QMessageBox::critical(this,"Warning", "Can't open file for writing",QMessageBox::Ok);return;}file.write(data);file.close();