标签:include 状态栏 parent 快捷键 file
#include "mymainwindow.h" #include "ui_mymainwindow.h" //#include <QMenuBar> //使用前向声明,不使用头文件包含的形式,主要是为了编译更快 class QMenuBar;//类的前向声明 myMainWindow::myMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::myMainWindow) { ui->setupUi(this); openAction = new QAction(tr("&open"),this); openAction->setShortcut(QKeySequence::Open);//动作的快捷键;比如:open快捷键 Ctrl+O(Qt的QKeySequence定义的) openAction->setStatusTip(tr("open a file"));//添加状态栏的提示语句 file = menuBar()->addMenu(tr("&File")); file->addAction(openAction); toolBar = addToolBar(tr("&File")); toolBar->addAction(openAction); } myMainWindow::~myMainWindow() { delete ui; }
运行之后,如图:
本文出自 “11907685” 博客,请务必保留此出处http://11917685.blog.51cto.com/11907685/1892012
标签:include 状态栏 parent 快捷键 file
原文地址:http://11917685.blog.51cto.com/11907685/1892012