当前位置:网站首页>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.";
}
}
边栏推荐
- Chinese name extraction (toy code - accurate head is too small, right to play)
- Explanation: here is your UFO, Goldbach conjecture
- 记忆函数的性能优化
- Mysql常用命令详细大全
- Numpy array calculation
- 为什么switch 的default后面要跟break?
- Operation tutorial: how does easydss convert MP4 on demand files into RTSP video streams?
- Android kotlin broadcast technology point
- Let juicefs help you with "remote backup"
- Redis database persistence
猜你喜欢
Can automatically update the universal weekly report template, you can use it with your hand!
2022 zero code / low code development white paper [produced by partner cloud] with download
Unity SKFramework框架(十二)、Score 计分模块
Countermeasures for the failure of MMPV billing period caused by negative inventory of materials in SAP mm
What are eNB, EPC and PGW?
三翼鸟两周年:羽翼渐丰,腾飞指日可待
2、 Frame mode MPLS operation
Solution: Compression Technology (original version and sequel version)
Daily practice of C language --- monkeys divide peaches
Chinese name extraction (toy code - accurate head is too small, right to play)
随机推荐
leetcode621. task scheduler
Crowncad (crown CAD), the first fully independent 3D CAD platform based on Cloud Architecture in China
Memory management 01 - link script
Unity small map production [2]
Unity SKFramework框架(十六)、Package Manager 開發工具包管理器
Unity skframework framework (XII), score scoring module
Quantum three body problem: Landau fall
Pointer from entry to advanced (1)
JS逆向之巨量创意signature签名
SSL证书的分类有哪些?如何选择合适的SSL证书?
D how to check null
Fundamentals of machine learning (II) -- division of training set and test set
Node. JS accessing PostgreSQL database through ODBC
三谈exception——错误处理
代码实现MNLM
最近公共祖先LCA的三种求法
Explanation: here is your UFO, Goldbach conjecture
Numpy array calculation
The 29 year old programmer in Shanghai was sentenced to 10 months for "deleting the database and running away" on the day of his resignation!
为什么switch 的default后面要跟break?