代码如下:
#include "mainwindow.h"
#include <QApplication>
#include <QDataStream>
#include <QFile>
#include <QtDebug>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
float f1=1.0;
QFile file("test.bat");
if (!file.open(QIODevice::WriteOnly))
{
qDebug()<<"error";
}
else
{
QDataStream out(&file);
out.setVersion(QDataStream::Qt_5_14);
out<<f1;
}
file.close();
MainWindow w;
w.show();
return a.exec();
}
二进制文件如下: