当前位置:网站首页>QT save qtextedit memory to Txt file
QT save qtextedit memory to Txt file
2022-06-22 04:51:00 【Small soup-】
01. Save button click slot function
// Avoid the file dialog box popping up twice
//Qt::UniqueConnection Ensure that there is only one connection between the same signal and the same slot function , Avoid triggering the slot function twice after clicking the button
connect(ui->buttonSave, SIGNAL(clicked()), this, SLOT(on_buttonSave_clicked()), Qt::UniqueConnection);
void Widget::on_buttonSave_clicked()
{
QFileDialog dlg(this);
// Get the saving path of the content
QString fileName = dlg.getSaveFileName(this, tr("Save As"), "./", tr("Text File(*.txt)"));
if( fileName == "" )
{
return;
}
// Save contents to path file
QFile file(fileName);
// Open... As text
if( file.open(QIODevice::WriteOnly | QIODevice::Text) )
{
QTextStream out(&file); //IO Initialize the device object by its address
out << ui->textEditRead->toPlainText() << endl; // Output
QMessageBox::warning(this, tr("Finish"), tr("Successfully save the file!"));
file.close();
}
else
{
QMessageBox::warning(this, tr("Error"), tr("File to open file!"));
}
}
02. Running effect

03. Reference resources
[ 1 ] Qt The opening of a text file 、 newly build 、 Save and save as
[ 2 ] Qt The reason for sending a signal to trigger the slot function twice
边栏推荐
- slurm 使用教程
- Lightweight CNN design skills
- Gavin's perception of transformer live class - NLU and policies data decryption, source code analysis and practice of insurance BOT in the insurance industry of Rasa dialogue robot project (57)
- Cloud function realizes fuzzy search function
- numpy库常用知识整理
- Lua exports as an external link library and uses
- 软考2022年下半年考试科目安排
- Segment tree & tree array template
- 爬梯子&&卖卖股份的最佳时期(跑路人笔记)
- 【使用指南】清华源的使用
猜你喜欢

Arrangement of soft test subjects in the second half of 2022

Ora - 15063: ASM discovered an insufficient number of Disks for diskgroup Recovery - - -

使用Echart绘制3D饼环图、仪表盘、电池图

Get the specified row content in Oracle rownum and row_ number()

IDS interview questions collection data structure + penetration avalanche + persistence + memory elimination strategy + database double write + Sentinel

QML控件类型:SwipeView、PageIndicator

Use echart to draw 3D pie chart, dashboard and battery diagram

Pourquoi golang ne recommande - t - il pas ceci / self / me / this / _ Ça.

轻量级CNN设计技巧

获取DPI函数返回值永远是96 | 获取DPI函数返回值不正确 | GetDpiForMonitor/GetDeviceCaps返回值不正确的原因
随机推荐
Go learning (II. Built in container)
厉害了!淮北两企业获准使用地理标志产品专用标志
【SDX62】IPA log抓取操作说明
Systematic arrangement | how many children's shoes have forgotten to be done carefully before the model development (practical operation)
tinymce. Init() browser compatibility issue
Pourquoi golang ne recommande - t - il pas ceci / self / me / this / _ Ça.
【故障诊断】CUDA kernel errors might be asynchronously reported at some other API call,so the stacktrace b
Progress information collection for progress control of Zhiyuan project management SPM system
Postman uses (reads) JSON files for batch testing
exness:欧洲央行行长拉加德重申计划在7月会议上加息
Learning signal integrity from scratch -- 7-si analysis and simulation
Importbeandefinitionregistrar registers beans with the container
Code example of map and entity class Interoperation
zipimport.ZipImportError:
Ora-15063: ASM discovered an insufficient number of disks for diskgroup
Debugging wechat built-in browser with chrome
Overrides vs overloads of methods
Specific concept of interceptor
[fault diagnosis] CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace B
【sdx62】QCMAP_ CLI manual dialing instructions