当前位置:网站首页>QT new project_ MyNotepad++
QT new project_ MyNotepad++
2022-07-02 13:48:00 【Across mountains and rivers, across the sea】
Qt The new project _MyNotepad++
How to create a menu bar
Hold down alt+F You can choose file (F)
The creation is successful, as shown in the figure below :
According to the above method, we create the effect of the following figure in turn
Yes Create new functions to expand
Function description :
When textEdit That text box Change when , Click New At the terminal output Prompt information .
Realization effect
Implementation code
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);
// Set title
this->setWindowTitle("ning_ning_WenDang");
QObject::connect(
ui->newAction,
SIGNAL(triggered()),
this,
SLOT(newFileSlot())
);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::newFileSlot()
{
// If the current document has changed
if(ui->textEdit->document()->isModified())
{
qDebug()<<"current file modified."; // Current document changes ;
}
else
{
qDebug()<<"not modified.";
}
}
边栏推荐
- [OpenGL] notes 29. Advanced lighting (specular highlights)
- Téléchargement par navigateur
- Numpy array calculation
- 能自动更新的万能周报模板,有手就会用!
- Android kotlin material design technology points
- 如何设置Qt手工布局
- P1347 排序(拓扑 + spfa判断环 or 拓扑[内判断环])
- The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
- Principle analysis of security rememberme
- Fundamentals of machine learning (II) -- division of training set and test set
猜你喜欢
随机推荐
Unity skframework framework (XII), score scoring module
2022 zero code / low code development white paper [produced by partner cloud] with download
Pointer from entry to advanced (1)
Dingtalk 发送消息
二、帧模式 MPLS 操作
Memory management 01 - link script
Use bloc to build a page instance of shutter
OpenFOAM:lduMatrix&lduAddressing
Principle analysis of security rememberme
Quantum three body problem: Landau fall
Essential for operation and maintenance - Elk log analysis system
P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
Why is the default of switch followed by break?
The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
Pocket Raider comments
Development skills of rxjs observable custom operator
D如何检查null
(POJ - 1984) navigation nightare (weighted and search set)
[document tree, setting] font becomes smaller
Verification failed, please check your call back website. You can follow the instructions