QT菜单栏工具在状态栏显示功能提示
#include "mainwindow.h" #include <QMenuBar> #include <QMessageBox> #include <QPushButton> #include <QStatusBar> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QMenuBar *qMenubar = this->menuBar(); QMenu *qMenu = qMenubar->addMenu("文件"); QAction *qAction = qMenu->addAction("新建"); qAction->setShortcut(QKeySequence::New); qAction->setStatusTip(tr("鼠标方式去在状态栏显示的提示")); //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); //带参数的时候 使用函数指针 QStatusBar *statusBar = this->statusBar(); }