Qt C++ QDataStream和QBuffer
- QBuffer用法
#include "mywidget.h" #include "ui_mywidget.h" #include <QBuffer> mywidget::mywidget(QWidget *parent) : QWidget(parent), ui(new Ui::mywidget) { ui->setupUi(this); QBuffer memfile; memfile.open(QIODevice::WriteOnly); memfile.write("青春时光多美妙热情奔放多欢笑");//写入缓冲区 memfile.close(); ui->textEdit->setText(memfile.buffer());//从缓冲区读取 }