当前位置:网站首页>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.";
}
}
边栏推荐
- Web基础
- Why can't d link DLL
- Daily practice of C language --- monkeys divide peaches
- OpenApi-Generator:简化RESTful API开发流程
- Halcon extract orange (Orange)
- 口袋奇兵点评
- 中文姓名提取(玩具代码——准头太小,权当玩闹)
- 题解《子数整数》、《欢乐地跳》、《开灯》
- Japan bet on national luck: Web3.0, anyway, is not the first time to fail!
- mysql ---- Oracle中的rownum转换成MySQL
猜你喜欢

Pointer from entry to advanced (1)

中文姓名提取(玩具代码——准头太小,权当玩闹)

无向图的桥

Solution: Compression Technology (original version and sequel version)

leetcode621. task scheduler

How to modify the error of easydss on demand service sharing time?

三翼鸟两周年:羽翼渐丰,腾飞指日可待

OpenFOAM:lduMatrix&lduAddressing

Unity skframework framework (XIV), extension extension function

TVOC, VOC, VOCs gas detection + Solution
随机推荐
Redis database persistence
Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
Why is the default of switch followed by break?
解答:EasyDSS视频点播时音频是否可以设置为默认开启?
Gee learning notes 2
Android kotlin broadcast technology point
【蓝桥杯选拔赛真题43】Scratch航天飞行 少儿编程scratch蓝桥杯选拔赛真题讲解
Daily question: 1175 Prime permutation
Unity skframework framework (XV), singleton singleton
SAP MM 因物料有负库存导致MMPV开账期失败问题之对策
代码实现MNLM
Can automatically update the universal weekly report template, you can use it with your hand!
Node.js通过ODBC访问PostgreSQL数据库
Detailed collection of common MySQL commands
[youcans' image processing learning course] general contents
Unity SKFramework框架(十六)、Package Manager 開發工具包管理器
[cloud native database] what to do when encountering slow SQL (Part 1)?
de4000h存储安装配置
Winter vacation daily question - lucky numbers in the matrix
[Blue Bridge Cup] children's worship circle

