/*
* File(F)
* New(N) Ctrl + N
* Open(O) Ctrl + O
* ----------------------------
* Close(C) Ctrl + Q
*/
QMenu *menuFile_ = new QMenu(tr("File(&F)"), this);
QAction *actionNew_ = menuFile_->addAction(QIcon("./images/new.png"), tr("New(&N)"));
actionNew_->setShortcut(QKeySequence(tr("Ctrl+N")));
QAction *actionOpen_ = menuFile_->addAction(QIcon("./images/open.png"), tr("Open(&O)"));
actionOpen_->setShortcut(QKeySequence(tr("Ctrl+O")));
menuFile_->addSeparator();
QAction *actionClose_ = menuFile_->addAction(tr("Close(&C)"));
QMenuBar *bar = menuBar(); //获取QMainWindow的菜单栏
bar->addMenu(menuFile_); //添加菜单
QToolBar *barFile_ = new QToolBar(tr("11"), this);
barFile_->addAction(actionNew_);
barFile_->addAction(actionOpen_);
barFile_->addAction(actionClose_);
barFile_->setAllowedAreas(Qt::LeftToolBarArea|Qt::TopToolBarArea);
barFile_->setOrientation(Qt::Vertical);
QMainWindow的成员函数添加工具栏 addToolBar(Qt::TopToolBarArea, barFile_);