QMessageBox信息模态对话框详细使用教程,对象创建栈和指针类型,对话框的风格样式设置,不要浪费实时间自己封装了,图文并茂,看图说话。

news2024/10/7 13:14:31

QMessageBox

  • 界面设计图
  • 展示效果
  • 【1】PC端使用QMessageBox
    • information (常规信息)
    • warning (警告消息)
    • critical (错误信息)
    • about (关于信息,无按钮)
    • question (问题信息?)
  • 嵌入式平台使用QMessageBox
    • QMessageBox (栈对象)
    • QMessageBox (指针对象)推荐使用这种
  • QMessageBox 缺点
  • 源码

这里分嵌入式和PC端两种

界面设计图

以上这些按钮全部通过直接转到槽即可
在这里插入图片描述

展示效果

所谓有图有真相,觉得是你项目需要的就拿去用
在这里插入图片描述
我用心设计的一个
在这里插入图片描述

【1】PC端使用QMessageBox

不需要自己设计和重新封装,直接调用
特色显示文本的地方其实就是QLabel类,官方在里面设置了他的图片和文本而已。
按钮同样如此,是QPushButton。这个框会根据你的文本内容动态调整,如果你想固定大小,可以通过样式表设置

information (常规信息)

[static] QMessageBox::StandardButton QMessageBox::information(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = Ok, QMessageBox::StandardButton defaultButton = NoButton)

内部函数实现

void MainWindow::on_PB_mBox_clicked()
{
    QMessageBox::information(this,"infomation","信息");
}

在这里插入图片描述


warning (警告消息)

[static] QMessageBox::StandardButton QMessageBox::warning(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = Ok, QMessageBox::StandardButton defaultButton = NoButton)
void MainWindow::on_PB_warning_clicked()
{
    QMessageBox::warning(this,"warning","信息");
}

在这里插入图片描述


critical (错误信息)

[static] QMessageBox::StandardButton QMessageBox::critical(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = Ok, QMessageBox::StandardButton defaultButton = NoButton)
void MainWindow::on_PB_error_clicked()
{
    QMessageBox::critical(this,"critical","信息");
}

在这里插入图片描述


about (关于信息,无按钮)

显示一个简单的关于具有标题标题和文本文本的框。

[static] void QMessageBox::about(QWidget *parent, const QString &title, const QString &text)
void MainWindow::on_PB_abort_clicked()
{
     QMessageBox::about(this,"about","信息");	

     QMessageBox::aboutQt(this,"aboutQt");	//显示Qt的官方介绍
}

在这里插入图片描述
在这里插入图片描述


question (问题信息?)

在指定的父小部件前面打开一个带有给定标题和文本的问题消息框。

[static] QMessageBox::StandardButton QMessageBox::question(QWidget *parent, const QString &title, const QString &text, QMessageBox::StandardButtons buttons = StandardButtons(Yes | No), QMessageBox::StandardButton defaultButton = NoButton)
void MainWindow::on_PB_quest_clicked()
{
    QMessageBox::question(this,"question","信息");
}

在这里插入图片描述


嵌入式平台使用QMessageBox

在嵌入式平台,有时是使用电阻屏和电容屏作为触摸屏幕。这个时候按钮文本都要设置的大一些,就要自己动点手了
这里分享两种,使用栈和指针的实现方式。

重点是样式设置

QMessageBox (栈对象)

我就不一个一个详细介绍了,根据自己的需要看一看吧。

void MainWindow::on_PB_struct_clicked()
{
    QMessageBox box;
    //去除标题和框
    box.setWindowFlag(Qt::FramelessWindowHint); //这种设置后,消息盒子无法移动了。
    box.resize(300,200);    //不起作用,原因未知。
    //设置窗口标题
    box.setWindowTitle("消息对话框");
    //设置标题
    box.setText(QString("<h3 style='text-align:center;'>温馨提示<h3>"));         //设置里面的Label的标题
    //设置新消息
    box.setInformativeText("你应该马上去学习!!!,否则你会落后。。。");  //Label里面的信息
    //设置按钮类型
    box.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
    //设置无按钮
    box.setStandardButtons(QMessageBox::NoButton);
    //按钮默认选中
    box.setDefaultButton(QMessageBox::No);
    //设置显示信息图标
    //box.setIcon(QMessageBox::Icon::Information);
    box.setIcon(QMessageBox::Icon::NoIcon);

    //添加自定义按钮,可以通过样式表设置按钮和标签的颜色。
    QPushButton *okButton = box.addButton(tr("确认"), QMessageBox::ButtonRole::ActionRole);
    //相当于占位符 没啥作用
    QPushButton *noneButton = box.addButton("              ",QMessageBox::ButtonRole::ActionRole);
    QPushButton *cancelButton = box.addButton("取消",QMessageBox::ButtonRole::RejectRole);

    //方式1
    okButton->setStyleSheet("QPushButton{padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    cancelButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
                     "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
    //文本虽然看不见,但按钮确认存在,需要设置不可点击。
    noneButton->setEnabled(false);
    noneButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:none;}");

//    //尝试设置按钮的样式(方式2) 不用定义指针 不用担心内存回收
//    foreach(auto i,box.buttons()){
//        qDebug()<<"i = "<<i->text();
//        if (i->text() == "确认") {
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
//                             "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
//        }
//        else if (i->text() == "取消") {
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
//                             "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
//        }
//        else {
//            i->setEnabled(false);
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;}");
//        }
//    }

    box.setStyleSheet("QMessageBox{background-color: rgb(0, 170, 255);color:#ffffff;border-radius:15px;}"
                      "QLabel{border-radius:15px;font-size:18px;min-width:150px;qproperty-alignment:AlignCenter;color:#ffffff;}"
                      );

    box.exec(); //模态事件一直循环,等待用户点击后响应。

    if (box.clickedButton() == okButton) {
        // do something
        qDebug()<<"确认";
    } else if (box.clickedButton() == cancelButton) {
        qDebug()<<"取消";
        // do something
    }
    else if (box.clickedButton() == noneButton) {
         //don't do
        qDebug()<<"关闭";
    }

    box.close();
}

在这里插入图片描述

QMessageBox (指针对象)推荐使用这种

在头文件创建了个消息盒子指针对象,在实际使用的地方创建也行,在这里创建是因为如果项目里面有很对提示框要显示,
整个类存在期间,都可以使用消息盒子。你也可以把所有有关的提示框封装成一个函数,通过引用传参的方式去显示消息盒子,可以减少代码量,提高效率。
在这里插入图片描述
函数实现
border-hover.png和border-pressed.png分别是按钮鼠标悬停和按压状态下的图片。10 20 10 20表示在按钮四个方向上的边框宽度,stretch stretch表示当按钮的大小改变时,图片应该如何拉伸来适应新的尺寸(水平 垂直拉伸)。

void MainWindow::on_PB_struct_2_clicked()
{
    qDebug()<<"================方法2======================";
    Pmsgbox = new QMessageBox;
    //去除标题和框
    Pmsgbox->setWindowFlag(Qt::FramelessWindowHint); //对话框无法在移动
    Pmsgbox->resize(300,200);    //不起作用
    //设置窗口标题
    Pmsgbox->setWindowTitle("消息对话框");
    //设置标题
    Pmsgbox->setText(QString("<h3 style='text-align:center;'>温馨提示<h3>"));         //设置里面的Label的标题
    //设置新消息
    Pmsgbox->setInformativeText("在上面的代码中,border.png是按钮边框的正常状态下的图片,"
                                "border-hover.png和border-pressed.png分别是按钮鼠标悬停和按压状态下的图片。"
                                "10 20 10 20表示在按钮四个方向上的边框宽度,stretch stretch表示当按钮的大小改变时,"
                                "图片应该如何拉伸来适应新的尺寸。"
                                "通过这种方式,你可以轻松地设置QMessageBox中按钮的外观和交互效果。");  //Label里面的信息
    //设置按钮类型
    Pmsgbox->setStandardButtons(QMessageBox::Ok | QMessageBox::No);
    //设置无按钮
    Pmsgbox->setStandardButtons(QMessageBox::NoButton);
    //按钮默认选中
    Pmsgbox->setDefaultButton(QMessageBox::No);
    //设置显示信息图标
    //box.setIcon(QMessageBox::Icon::Information);  //根据需要显示对应的图片
    Pmsgbox->setIcon(QMessageBox::Icon::NoIcon);
    //设置盒子固定大小,不会随文本自动调整
    Pmsgbox->setFixedSize(300,150); //无效,不知道为啥

    //添加自定义按钮,可以通过样式表设置按钮和标签的颜色。
    QPushButton *okButton = Pmsgbox->addButton(tr("确认"), QMessageBox::ButtonRole::ActionRole);
    //相当于占位符 没啥作用
    QPushButton *noneButton = Pmsgbox->addButton("              ",QMessageBox::ButtonRole::ActionRole);
    QPushButton *cancelButton = Pmsgbox->addButton("取消",QMessageBox::ButtonRole::RejectRole);

    //方式1
    okButton->setStyleSheet("QPushButton{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    cancelButton->setStyleSheet("QPushButton{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    //文本虽然看不见,但按钮确认存在,需要设置不可点击。
    noneButton->setEnabled(false);
    noneButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:none;}");

    //盒子宽高无效
    Pmsgbox->setStyleSheet("QMessageBox{background-color: rgb(0, 170, 255);color:#ffffff;border-radius:15px;}"
                      "QLabel{border-radius:15px;font-size:18px;min-width:150px;min-height:80px;qproperty-alignment:AlignCenter;color:#ffffff;}"
                      );

    //不可以。QMessageBox是一种模态对话框,当它被显示时,其他界面控件会被禁用,直到用户关闭该对话框。
    Pmsgbox->exec(); //模态事件一直循环,等待用户点击后响应。
    // Pmsgbox->setVisible(true);  //还是无法点击其他按钮
    //Pmsgbox->show();

    //您可以在显示QMessageBox的同时,使用QApplication::processEvents()函数处理其他事件,这样就可以让其他按钮被点击。例如:
   // QApplication::processEvents();//还是无效

    if (Pmsgbox->clickedButton() == okButton) {
        // do something
        qDebug()<<"确认";
    } else if (Pmsgbox->clickedButton() == cancelButton) {
        qDebug()<<"取消";
        // do something
    }
    else if (Pmsgbox->clickedButton() == noneButton) {
         //don't do
        qDebug()<<"关闭";
    }

    //Pmsgbox->close();
}

运行效果
在这里插入图片描述

鼠标按钮时
在这里插入图片描述


QMessageBox 缺点

可能他的缺点就是他的优点吧!!!

【1】显示的框都是模态的,不管哪种函数来显示,即这个框显示的时候,界面上的其他按钮无法点击,在大型项目中,内部代码的多线程,信号与槽的连接,会不会有什么影响不得而知。就是你必须做完这件事,才能去做下一件事。
【2】设置按钮风格和文本风格只能通过样式表设置。

就简单记录下,大佬莫喷

源码

头文件

#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 slots:
    void on_PB_mBox_clicked();
    void on_PB_warning_clicked();
    void on_PB_error_clicked();
    void on_PB_struct_clicked();
    void on_PB_abort_clicked();
    void on_PB_quest_clicked();
    void on_toolButton_clicked();
    void on_PB_struct_2_clicked();
private:
    Ui::MainWindow *ui;
    QMessageBox *Pmsgbox = nullptr;
};
#endif // MAINWINDOW_H

源文件

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_PB_mBox_clicked()
{
    QMessageBox::information(this,"infomation","信息");
}

void MainWindow::on_PB_warning_clicked()
{
    QMessageBox::warning(this,"warning","信息");
}

void MainWindow::on_PB_error_clicked()
{
    QMessageBox::critical(this,"critical","信息");
}
void MainWindow::on_PB_abort_clicked()
{
     QMessageBox::about(this,"about","信息");

     QMessageBox::aboutQt(this,"aboutQt");
}
void MainWindow::on_PB_quest_clicked()
{
    QMessageBox::question(this,"question","信息");
}
void MainWindow::on_PB_struct_clicked()
{
    QMessageBox box;
    //去除标题和框
    box.setWindowFlag(Qt::FramelessWindowHint);
    box.resize(300,200);    //不起作用
    //设置窗口标题
    box.setWindowTitle("消息对话框");
    //设置标题
    box.setText(QString("<h3 style='text-align:center;'>温馨提示<h3>"));         //设置里面的Label的标题
    //设置新消息
    box.setInformativeText("你应该马上去学习!!!,否则你会落后。。。");  //Label里面的信息
    //设置按钮类型
    box.setStandardButtons(QMessageBox::Ok | QMessageBox::No);
    //设置无按钮
    box.setStandardButtons(QMessageBox::NoButton);
    //按钮默认选中
    box.setDefaultButton(QMessageBox::No);
    //设置显示信息图标
    //box.setIcon(QMessageBox::Icon::Information);
    box.setIcon(QMessageBox::Icon::NoIcon);

    //添加自定义按钮,可以通过样式表设置按钮和标签的颜色。
    QPushButton *okButton = box.addButton(tr("确认"), QMessageBox::ButtonRole::ActionRole);
    //相当于占位符 没啥作用
    QPushButton *noneButton = box.addButton("              ",QMessageBox::ButtonRole::ActionRole);
    QPushButton *cancelButton = box.addButton("取消",QMessageBox::ButtonRole::RejectRole);

    //方式1
    okButton->setStyleSheet("QPushButton{padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    cancelButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
                     "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
    //文本虽然看不见,但按钮确认存在,需要设置不可点击。
    noneButton->setEnabled(false);
    noneButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:none;}");

//    //尝试设置按钮的样式(方式2) 不用定义指针 不用担心内存回收
//    foreach(auto i,box.buttons()){
//        qDebug()<<"i = "<<i->text();
//        if (i->text() == "确认") {
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
//                             "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
//        }
//        else if (i->text() == "取消") {
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png');}"
//                             "QPushButton:pressed{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png');}");
//        }
//        else {
//            i->setEnabled(false);
//            i->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;}");
//        }
//    }

    box.setStyleSheet("QMessageBox{background-color: rgb(0, 170, 255);color:#ffffff;border-radius:15px;}"
                      "QLabel{border-radius:15px;font-size:18px;min-width:150px;qproperty-alignment:AlignCenter;color:#ffffff;}"
                      );

    box.exec(); //模态事件一直循环,等待用户点击后响应。

    if (box.clickedButton() == okButton) {
        // do something
        qDebug()<<"确认";
    } else if (box.clickedButton() == cancelButton) {
        qDebug()<<"取消";
        // do something
    }
    else if (box.clickedButton() == noneButton) {
         //don't do
        qDebug()<<"关闭";
    }

    box.close();
}

void MainWindow::on_PB_struct_2_clicked()
{
    qDebug()<<"================2";
    Pmsgbox = new QMessageBox;
    //去除标题和框
    Pmsgbox->setWindowFlag(Qt::FramelessWindowHint);
    Pmsgbox->resize(300,200);    //不起作用
    //设置窗口标题
    Pmsgbox->setWindowTitle("消息对话框");
    //设置标题
    Pmsgbox->setText(QString("<h3 style='text-align:center;'>温馨提示<h3>"));         //设置里面的Label的标题
    //设置新消息
    Pmsgbox->setInformativeText("在上面的代码中,border.png是按钮边框的正常状态下的图片,"
                                "border-hover.png和border-pressed.png分别是按钮鼠标悬停和按压状态下的图片。"
                                "10 20 10 20表示在按钮四个方向上的边框宽度,stretch stretch表示当按钮的大小改变时,"
                                "图片应该如何拉伸来适应新的尺寸。"
                                "通过这种方式,你可以轻松地设置QMessageBox中按钮的外观和交互效果。");  //Label里面的信息
    //设置按钮类型
    Pmsgbox->setStandardButtons(QMessageBox::Ok | QMessageBox::No);
    //设置无按钮
    Pmsgbox->setStandardButtons(QMessageBox::NoButton);
    //按钮默认选中
    Pmsgbox->setDefaultButton(QMessageBox::No);
    //设置显示信息图标
    //box.setIcon(QMessageBox::Icon::Information);
    Pmsgbox->setIcon(QMessageBox::Icon::NoIcon);
    //设置盒子固定大小,不会随文本自动调整
    Pmsgbox->setFixedSize(300,150); //无效

    //添加自定义按钮,可以通过样式表设置按钮和标签的颜色。
    QPushButton *okButton = Pmsgbox->addButton(tr("确认"), QMessageBox::ButtonRole::ActionRole);
    //相当于占位符 没啥作用
    QPushButton *noneButton = Pmsgbox->addButton("              ",QMessageBox::ButtonRole::ActionRole);
    QPushButton *cancelButton = Pmsgbox->addButton("取消",QMessageBox::ButtonRole::RejectRole);

    //方式1
    okButton->setStyleSheet("QPushButton{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    cancelButton->setStyleSheet("QPushButton{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_7_d.png') 20 20 20 20 stretch stretch;}"
                     "QPushButton:pressed{border-radius:10px;padding:10px;color: rgb(255, 255, 255);font-size:30px;border-image:url(':/pic/button_10_d.png') 20 20 20 20 stretch stretch;}");
    //文本虽然看不见,但按钮确认存在,需要设置不可点击。
    noneButton->setEnabled(false);
    noneButton->setStyleSheet("QPushButton{border-radius:15px;color: rgb(255, 255, 255);font-size:30px;border-image:none;}");

    //盒子宽高无效
    Pmsgbox->setStyleSheet("QMessageBox{background-color: rgb(0, 170, 255);color:#ffffff;border-radius:15px;}"
                      "QLabel{border-radius:15px;font-size:18px;min-width:150px;min-height:80px;qproperty-alignment:AlignCenter;color:#ffffff;}"
                      );

    //不可以。QMessageBox是一种模态对话框,当它被显示时,其他界面控件会被禁用,直到用户关闭该对话框。
    Pmsgbox->exec(); //模态事件一直循环,等待用户点击后响应。
    // Pmsgbox->setVisible(true);  //还是无法点击其他按钮
    //Pmsgbox->show();

    //您可以在显示QMessageBox的同时,使用QApplication::processEvents()函数处理其他事件,这样就可以让其他按钮被点击。例如:
   // QApplication::processEvents();//还是无效

    if (Pmsgbox->clickedButton() == okButton) {
        // do something
        qDebug()<<"确认";
    } else if (Pmsgbox->clickedButton() == cancelButton) {
        qDebug()<<"取消";
        // do something
    }
    else if (Pmsgbox->clickedButton() == noneButton) {
         //don't do
        qDebug()<<"关闭";
    }

    //Pmsgbox->close();
}



void MainWindow::on_toolButton_clicked()
{
    for(int i = 0; i < 1000; ++i)
    {
        qDebug()<<"i = "<<i<<endl;
    }
}


资源文件
在这里插入图片描述


END

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/609573.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Android开发 LogDog (日志狗)V2.0.0

目录 一、简介 二、使用推荐 1、初始化LogDog 2、运行中如何更改初始化时的配置&#xff1f; 三、更改 四、新功能 1、Log过滤 2、自定义打印 3、提供占位符式打印 一、简介 LogDog V1.0 版本https://blog.csdn.net/Ym_quiet/article/details/130453232?spm1001.2014…

javascript基础二十六:JavaScript中如何实现函数缓存?有哪些应用场景?

一、是什么 函数缓存&#xff0c;就是将函数运算过的结果进行缓存 本质上就是用空间&#xff08;缓存存储&#xff09;换时间&#xff08;计算过程&#xff09; 常用于缓存数据计算结果和缓存对象 const add (a,b) > ab; const calc memoize(add); // 函数缓存 calc(1…

Linux邮件发送教程:深入了解mail命令

前言 大家好&#xff0c;又见面了&#xff0c;我是沐风晓月&#xff0c;本文是专栏【linux基本功-基础命令实战】的第59篇文章。 专栏地址&#xff1a;[linux基本功-基础命令专栏] &#xff0c; 此专栏是沐风晓月对Linux常用命令的汇总&#xff0c;希望能够加深自己的印象&am…

Java进行公众号开发的常见使用场景及解决方案

Java进行公众号开发的常见使用场景解决方案 文章简介 本文总结了本人在开发过程中遇到的有关于微信开发的诸多常见功能&#xff0c;这些问题在网上找都是零散的回答&#xff0c;所以再此总结一下&#xff0c;方便后续开发。如果有错误之处&#xff0c;还望批评指出&#xff0…

使用Kaggle GPU资源免费体验Stable Diffusion开源项目

使用Kaggle GPU资源免费体验Stable Diffusion开源项目 前言相关介绍Stable Diffusion Kaggle开源项目编辑并复制项目运行项目打开网址&#xff0c;即可体验 参考 前言 由于本人水平有限&#xff0c;难免出现错漏&#xff0c;敬请批评改正。更多精彩内容&#xff0c;可点击进入Y…

javascript基础二十五:说说你对函数式编程的理解?优缺点?

一、是什么 函数式编程是一种"编程范式"&#xff08;programming paradigm&#xff09;&#xff0c;一种编写程序的方法论 主要的编程范式有三种&#xff1a;命令式编程&#xff0c;声明式编程和函数式编程 相比命令式编程&#xff0c;函数式编程更加强调程序执行…

C SS复习笔记

1.img标签 img的src属性是图片显示不出来时显示的文字 ing的title属性是光标放到图片上&#xff0c;提示的文字 2.a标签 a标签的target属性表示打开窗口的方式&#xff0c;默认的值是_self表示当前窗口的打开页面&#xff0c;_blank表示新窗口打开页面。 a标签的href链接分…

2023.06.04 学习周报

文章目录 摘要文献阅读1.题目2.背景3.方案4.本文贡献5.模型5.1 图注意力形式5.2 superGAT 6.实验7.结论 有限元数学建模深度学习1.高斯扩散2.原理 总结 摘要 This week, I read a computer science about GNN. At present, the attention mechanism of graph neural network i…

Go Web下GORM框架使用(二)

〇、前言 本文将会写一个前后端分离的的小项目&#xff0c;本文将会只实现后端。 一、定义全局变量与模型 本文需要一个数据库&#xff0c;因此将这个数据库定义为全局变量将会非常轻松。 var (DB *gorm.DB )type Todo struct {ID int json:"id"Title s…

【C#图解教程】第六章 方法(下)

输出参数 函数的输出只有返回值有时不太够&#xff0c;此时需要用到输出参数&#xff0c;用修饰词out声明 输出参数的要求与引用参数类似&#xff0c;需要是变量&#xff0c;此外&#xff0c;输出参数也是实参的别名&#xff0c;指向堆中同一对象。 输出参数与引用参数的不同在…

【实用篇】Elasticsearch03

文章目录 分布式搜索引擎031.数据聚合1.1.聚合的种类1.2.DSL实现聚合1.2.1.Bucket聚合语法1.2.2.聚合结果排序1.2.3.限定聚合范围1.2.4.Metric聚合语法1.2.5.小结 1.3.RestAPI实现聚合1.3.1.API语法1.3.2.业务需求1.3.3.业务实现 2.自动补全2.1.拼音分词器2.2.自定义分词器2.3.…

【人工智能】— Support Vector Machines 支持向量机

【人工智能】— Support Vector Machines 支持向量机 支持向量机概述支持向量机支持向量机原理介绍分类间距&#xff08;Classification Margin&#xff09; 支持向量机概述 找到使间隔最大化的超平面>B1比B2更好 支持向量机 研究起因&#xff1a;如何找到最优的切分面 分…

制作酷炫可视化大屏利器--分享10种比较流行的开源免费的图表库

在开发可视化项目的过程中往往涉及到可视化图表, 多酷炫的报表, 大屏, 都用了非常多的图表, 接下来我和大家分享一些比较流行的开源免费的图表库. 分享10种比较流行的开源免费的图表库 1&#xff0c;Frappe Charts2&#xff0c;Recharts3&#xff0c;Protovis4&#xff0c;dygr…

Docker快速入门(分分钟钟就能上手)

Docker的思想 集装箱&#xff1a;会将所有需要的内容放到不同的集装箱中&#xff0c;谁需要这些环境就直接拿到这个集装箱就可以了。标准化&#xff1a; 运输的标准化&#xff1a;Docker有一个码头&#xff0c;所有上传的集装箱都放在了这个码头上&#xff0c;当谁需要某一个环…

设计模式-01.设计思想

设计思想 此系列文章非本人原创&#xff0c;是学习笔记。 下面讲一些常见的设计思想 基于接口而非实现编程 这个原则非常重要&#xff0c;是一种非常有效的提高代码质量的手段&#xff0c;在平时的开发中特别经常被用到。 如何解读原则中的“接口”二字&#xff1f; “基于…

python面向对象操作1(速通版)

目录 一、高阶函数 1.lambda函数 2.lambda函数注意事项 3.map用法 4.map和lambda函数配合 二、reduce函数 1.reduce基本应用 2.reduce和匿名函数配合 三、filter()函数 1.简单用法 2.高阶应用 四、列表排列方法&#xff08;key和lambda问题&#xff09; 1.正常排序…

Node服务器和常见模块

1 Node服务器开发 2 fs模块-文件系统 3 event模块-事件处理 4 认识二进制和buffer 5 Buffer的创建方式 6 Buffer的源码解析 node 的fs模块操作&#xff1a; 这里主要讲node如何进行读取文件&#xff0c;操作文件。服务器该有的操作node都有。 node的fs读取文本文件内容的d…

自定义starter

第一步、创建 xxx-spring-boot-starter 的spring Initializr模块 第二步、删除不需要的内容&#xff08;启动类、除下面spring-boot-starter的其它依赖&#xff0c;maven编译插件&#xff09; <dependency><groupId>org.springframework.boot</groupId><…

linux理解软硬链接

软硬连接 在linux下面链接文件有两种&#xff0c;一种是类似window的快捷方式功能的文件&#xff0c;可以让你快速链接到目标文件&#xff08;或目录&#xff09;&#xff0c;叫做软链接&#xff0c;另一种则是通过文件系统的inode链接来产生新的文件名&#xff0c;而不是产生…

Linux 常用开发工具(yum、vim)

绪论 耐心是一切聪明才智的基础。—— 柏拉图。本章进入到Linux下的一些常用的工具&#xff0c;这些工具能帮助我们去更好的使用Linux操作系统。 话不多说安全带系好&#xff0c;发车啦&#xff08;建议电脑观看&#xff09;。 附&#xff1a;红色&#xff0c;部分为重点部分&a…