Qt记事本功能齐全,主要实现打开、新建、保存、另存为、查找、居中、字体、颜色、剪切、复制、粘贴等功能

上传者: 44835740 | 上传时间: 2021-03-25 17:00:42 | 文件大小: 832KB | 文件类型: ZIP
运用Qt开发工具来实现一个记事本,用户图形界面操作,通过Qt提供的图形库来设计记事本的管理、应用基本窗口,主要实现打开、新建、保存、另存为、查找、居中、字体、颜色等功能设计,同时在软件内部实现对于这些功能的支持和实现。还有对用户剪切、复制、粘贴、等功能的支持 核心代码讲解 1、打开文件功能 void MainWindow::on_action_2_triggered() { QString filename = QFileDialog::getOpenFileName(this); loadFile(filename); } 打开文件on_action_2_triggered()通过转到槽实现首先定义一个Qstring类型的filename让它获取你文件名,其次寻找它的本地连接。 3、保存文件功能 void MainWindow::on_action_3_triggered() { if(isSaved){ saveFile(curFile); } else{ do_file_SaveAS(); } } 保存文件功能on_action_3_triggered()通过转到槽实现,先判断bool型的isSaved是否是正确的,如果错则保存当前文件,否则执行另存为。 5、关闭功能 void MainWindow::on_action_5_triggered() { if(close){ QMessageBox::information(this,"提示","文件尚未保存,关闭"); }else{ ui->textEdit->close(); } } 关闭功能on_action_5_triggered()先对文本进行判断是否是关闭的,如果是错弹出对话框提示消息文件尚未保存,关闭,否则对文档进行关闭 11、查找功能 //查找 void MainWindow::close_findhangshu() { ui->gridLayoutWidget->close(); } close_findhangshu()对查找对话框进行关闭函数。 void MainWindow::on_action_11_triggered() { QDialog *closefind=new QDialog(this); QDialog *findDlg=new QDialog(this); find_textLineEdit=new QLineEdit(findDlg); QPushButton *find_Bth=new QPushButton(tr("查找下一个"),findDlg); QPushButton *close_find=new QPushButton(tr("关闭"),closefind); ui->gridLayout->addWidget(find_textLineEdit); ui->gridLayout->addWidget(find_Bth); ui->gridLayout->addWidget(close_find); connect(find_Bth,SIGNAL(clicked()),this,SLOT(show_findText())); connect(close_find,SIGNAL(clicked()),this,SLOT(close_findhangshu())); } 查找功能on_action_11_triggered()函数通过转到槽实现下面部分:先定义两个QDialog类型 指针变量*closefind和*findDlg,对它们进行新创建空间, find_textLineEdit=new QLineEdit(findDlg);新建一个空间对QlineEdit它进行传参,将findDlg传入目的是查找在文档中对应的文字,QPushButton *find_Bth=new QPushButton(tr("查找下一个"),findDlg);QPushButton *close_find=new QPushButton(tr("关闭"),closefind);这两个代码作用相同定义两个Qpubutton当点击查找功能弹出对话框时在对话框中实现查找下一个和关闭connect(find_Bth,SIGNAL(clicked()),this,SLOT(show_findText()));connect(close_find,SI

文件下载

资源详情

[{"title":"( 57 个子文件 832KB ) Qt记事本功能齐全,主要实现打开、新建、保存、另存为、查找、居中、字体、颜色、剪切、复制、粘贴等功能","children":[{"title":"QtTest","children":[{"title":"QtTest","children":[{"title":"QtTest.pro <span style='color:#111;'> 444B </span>","children":null,"spread":false},{"title":"QtTest.pro.user.ce838ff <span style='color:#111;'> 40.60KB </span>","children":null,"spread":false},{"title":"QtTest.pro.user <span style='color:#111;'> 40.60KB </span>","children":null,"spread":false},{"title":"QtTest.pro.user.12 <span style='color:#111;'> 17.24KB </span>","children":null,"spread":false},{"title":"main.cpp <span style='color:#111;'> 187B </span>","children":null,"spread":false},{"title":"mainwindow.ui <span style='color:#111;'> 10.14KB </span>","children":null,"spread":false},{"title":"mainwindow.cpp <span style='color:#111;'> 6.38KB </span>","children":null,"spread":false},{"title":"mainwindow.h <span style='color:#111;'> 1.63KB </span>","children":null,"spread":false},{"title":"QtTest.pro.user.f47745a <span style='color:#111;'> 17.33KB </span>","children":null,"spread":false}],"spread":true},{"title":"build-QtTest-Desktop_Qt_5_0_2_MinGW_32bit-Debug","children":[{"title":"Makefile.Debug <span style='color:#111;'> 34.54KB </span>","children":null,"spread":false},{"title":"Makefile.Release <span style='color:#111;'> 34.60KB </span>","children":null,"spread":false},{"title":"ui_mainwindow.h <span style='color:#111;'> 8.06KB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"moc_mainwindow.cpp <span style='color:#111;'> 3.97KB </span>","children":null,"spread":false},{"title":"moc_mainwindow.o <span style='color:#111;'> 164.67KB </span>","children":null,"spread":false},{"title":"mainwindow.o <span style='color:#111;'> 275.61KB </span>","children":null,"spread":false},{"title":"main.o <span style='color:#111;'> 124.10KB </span>","children":null,"spread":false}],"spread":true},{"title":"Makefile <span style='color:#111;'> 13.27KB </span>","children":null,"spread":false},{"title":"release","children":null,"spread":false}],"spread":true},{"title":"build-QtTest-Desktop_x86_windows_msys_pe_32bit-Debug","children":[{"title":"Makefile.Debug <span style='color:#111;'> 36.42KB </span>","children":null,"spread":false},{"title":"Makefile.Release <span style='color:#111;'> 36.51KB </span>","children":null,"spread":false},{"title":"ui_mainwindow.h <span style='color:#111;'> 14.86KB </span>","children":null,"spread":false},{"title":"debug","children":[{"title":"qrc_pic.cpp <span style='color:#111;'> 115.99KB </span>","children":null,"spread":false},{"title":"moc_mainwindow.cpp <span style='color:#111;'> 7.95KB </span>","children":null,"spread":false},{"title":"moc_mainwindow.o <span style='color:#111;'> 159.48KB </span>","children":null,"spread":false},{"title":"qrc_pic.o <span style='color:#111;'> 30.85KB </span>","children":null,"spread":false},{"title":"mainwindow.o <span style='color:#111;'> 465.18KB </span>","children":null,"spread":false},{"title":"main.o <span style='color:#111;'> 124.10KB </span>","children":null,"spread":false},{"title":"QtTest.exe <span style='color:#111;'> 909.32KB </span>","children":null,"spread":false}],"spread":true},{"title":"Makefile <span style='color:#111;'> 11.56KB </span>","children":null,"spread":false},{"title":"release","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"QtPicture","children":[{"title":"ͼƬ4.png <span style='color:#111;'> 797B </span>","children":null,"spread":false},{"title":"ͼƬ13.png <span style='color:#111;'> 893B </span>","children":null,"spread":false},{"title":"ͼƬ8.png <span style='color:#111;'> 311B </span>","children":null,"spread":false},{"title":"ͼƬ12.png <span style='color:#111;'> 756B </span>","children":null,"spread":false},{"title":"32.png <span style='color:#111;'> 1.67KB </span>","children":null,"spread":false},{"title":"ͼƬ18.png <span style='color:#111;'> 475B </span>","children":null,"spread":false},{"title":"ͼƬ7.png <span style='color:#111;'> 208B </span>","children":null,"spread":false},{"title":"ͼƬ14.png <span style='color:#111;'> 1.16KB </span>","children":null,"spread":false},{"title":"ͼƬ6.png <span style='color:#111;'> 907B </span>","children":null,"spread":false},{"title":"ͼƬ19.png <span style='color:#111;'> 730B </span>","children":null,"spread":false},{"title":"ͼƬ9.png <span style='color:#111;'> 312B </span>","children":null,"spread":false},{"title":"1.qrc <span style='color:#111;'> 101B </span>","children":null,"spread":false},{"title":"ͼƬ23.png <span style='color:#111;'> 1.27KB </span>","children":null,"spread":false},{"title":"ͼƬ5.png <span style='color:#111;'> 1.05KB </span>","children":null,"spread":false},{"title":"33.png <span style='color:#111;'> 1.66KB </span>","children":null,"spread":false},{"title":"ͼƬ20.png <span style='color:#111;'> 942B </span>","children":null,"spread":false},{"title":"ͼƬ1.png <span style='color:#111;'> 910B </span>","children":null,"spread":false},{"title":"ͼƬ21.png <span style='color:#111;'> 305B </span>","children":null,"spread":false},{"title":"30.png <span style='color:#111;'> 2.45KB </span>","children":null,"spread":false},{"title":"ͼƬ11.png <span style='color:#111;'> 1.57KB </span>","children":null,"spread":false},{"title":"ͼƬ3.png <span style='color:#111;'> 845B </span>","children":null,"spread":false},{"title":"ͼƬ15.png <span style='color:#111;'> 1.12KB </span>","children":null,"spread":false},{"title":"pic.qrc <span style='color:#111;'> 903B </span>","children":null,"spread":false},{"title":"ͼƬ10.png <span style='color:#111;'> 324B </span>","children":null,"spread":false},{"title":"ͼƬ16.png <span style='color:#111;'> 929B </span>","children":null,"spread":false},{"title":"ͼƬ22.png <span style='color:#111;'> 853B </span>","children":null,"spread":false},{"title":"ͼƬ24.png <span style='color:#111;'> 700B </span>","children":null,"spread":false},{"title":"ͼƬ2.png <span style='color:#111;'> 989B </span>","children":null,"spread":false},{"title":"ͼƬ17.png <span style='color:#111;'> 1.24KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明