当前位置:网站首页>Qt新项目_MyNotepad++
Qt新项目_MyNotepad++
2022-07-02 10:18:00 【踏过山河,踏过海】
创建菜单栏的方法
按住alt+F就能选中文件(F)
创建成功如下图所示:
根据上面的方法我们依次创建下图的效果
对 新建功能进行开拓
功能描述:
当textEdit那个文本框发生改变时,点击新建 就在终端输出提示信息.
实现效果
实现代码
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QMessageBox>
#include <QDebug>
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
private slots:
void newFileSlot();
};
#endif // MAINWINDOW_H
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//设置标题
this->setWindowTitle("ning_ning_WenDang");
QObject::connect(
ui->newAction,
SIGNAL(triggered()),
this,
SLOT(newFileSlot())
);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::newFileSlot()
{
//如果当前的文档已将改变了
if(ui->textEdit->document()->isModified())
{
qDebug()<<"current file modified."; //当前文档改变;
}
else
{
qDebug()<<"not modified.";
}
}
边栏推荐
- Solve "sub number integer", "jump happily", "turn on the light"
- Embedded software development
- On flow delivery between microservices
- 为什么switch 的default后面要跟break?
- Unity skframework framework (XV), singleton singleton
- OpenFOAM:lduMatrix&lduAddressing
- 题解:《你的飞碟在这儿》、《哥德巴赫猜想》
- How to modify the error of easydss on demand service sharing time?
- 【云原生数据库】遇到慢SQL该怎么办(上)?
- OpenApi-Generator:简化RESTful API开发流程
猜你喜欢
Essential for operation and maintenance - Elk log analysis system
大家信夫一站式信用平台让信用场景“用起来
Node.js通过ODBC访问PostgreSQL数据库
不会看器件手册的工程师不是个好厨子
Answer: can the audio be set to on by default during easydss video on demand?
记忆函数的性能优化
OpenFOAM:lduMatrix&lduAddressing
Unity skframework framework (XVI), package manager development kit Manager
Japan bet on national luck: Web3.0, anyway, is not the first time to fail!
能自动更新的万能周报模板,有手就会用!
随机推荐
Bridge of undirected graph
Unity skframework framework (XVIII), roamcameracontroller roaming perspective camera control script
Solution: Compression Technology (original version and sequel version)
On flow delivery between microservices
SSL证书的分类有哪些?如何选择合适的SSL证书?
Unity skframework framework (XII), score scoring module
Mysql常用命令详细大全
Principle analysis of security rememberme
Unity SKFramework框架(十三)、Question 问题模块
Let juicefs help you with "remote backup"
[cloud native database] what to do when encountering slow SQL (Part 1)?
Gee learning notes 2
Redis数据库持久化
Independent and controllable 3D cloud CAD: crowncad enables innovative design of enterprises
Dingtalk 发送消息
OpenApi-Generator:简化RESTful API开发流程
题解:《压缩技术》(原版、续集版)
机器学习基础(二)——训练集和测试集的划分
nohup命令
大家信夫一站式信用平台让信用场景“用起来