麦田

不积跬步无以至千里.

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  445 随笔 :: 16 文章 :: 192 评论 :: 95万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
复制代码
#include "mainwindow.h"

#include <QMenuBar>
#include <QMessageBox>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    QMenuBar *qMenubar = this->menuBar();
    QMenu *qMenu = qMenubar->addMenu("文件");
    QAction *qAction = qMenu->addAction("新建");
    qAction->setShortcut(QKeySequence::New);

    //connect(qAction,&QAction::triggered,this,&MainWindow::DealSlot); //无参函数的时候 直接&获取函数指针

    //connect(qAction,SIGNAL(triggered()),this,SLOT(DealSlot())); //使用宏

    void (QAction::*pTriggered)(bool) = &QAction::triggered;
    void (MainWindow::*pDealSlot)() = &MainWindow::DealSlot;
    connect(qAction,pTriggered,this,pDealSlot); //带参数的时候 使用函数指针
}

MainWindow::~MainWindow()
{
}

void MainWindow::DealSlot()
{
    QMessageBox msgBox;
      msgBox.setText("The document has been modified.");
      msgBox.exec();
}
复制代码

 

posted on   一些记录  阅读(1893)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Ollama——大语言模型本地部署的极速利器
· 使用C#创建一个MCP客户端
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· Windows编程----内核对象竟然如此简单?
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
点击右上角即可分享
微信分享提示