0
点赞
收藏
分享

微信扫一扫

(12)菜单栏、工具栏和状态栏


 

 

openAction = new QAction(QIcon(":/images/doc-open"), tr("&Open..."), this);
openAction->setShortcuts(QKeySequence::Open);
openAction->setStatusTip(tr("Open an existing file"));
connect(openAction, &QAction::triggered, this, MainWindow::open);

QMenu *file = menuBar()->addMenu(tr("&File"));
file->addAction(openAction);

QToolBar *toolBar = addToolBar(tr("&File"));
toolBar->addAction(openAction);

Qt 中,表示菜单的类是​​QMenuBar​​​。​​QMenuBar​​代表的是窗口最上方的一条菜单栏。

我们使用其​​addMenu()​​函数为其添加菜单。

​QToolBar​​​就是工具栏。我们使用的是​​addToolBar()​​函数添加新的工具栏。

 

QToolBar *toolBar2 = addToolBar(tr("Tool Bar 2"));
toolBar2->addAction(openAction);

statusBar();

​QStatusBar​​​继承了​​QWidget​​​,因此,我们可以将其它任意​​QWidget​​子类添加到状态栏,从而实现类似 Photoshop 窗口底部那种有比例显示、有网格开关的复杂状态栏。

 

 

 

举报

相关推荐

0 条评论