一. QStatusBar 状态栏
它只有在QMainWindow才有,其它没有,但是可以手动添加,如下:
设置Label
然后放到状态栏里:
.h
:
#include <QLabel>
#include <QProgressBar>
// 用于状态栏显示
QLabel *statusLabel;
QProgressBar *statusProgressBar;
.c
:
// create objects for the label and progress bar
statusLabel = new QLabel(this);
statusProgressBar = new QProgressBar(this);
// set text for the label
statusLabel->setText("Status Label");
// make progress bar text invisible
statusProgressBar->setTextVisible(false);
ui->statusBar->addWidget(statusLabel);
ui->statusBar->addWidget(statusProgressBar);
二. QToolBar
- 里面加的是 QAction
ui->toolBar->addAction(ui->actListAdd);
添加下拉按钮步骤:
- 先在 desiger 里新建一个 Action:
actSelPopMen
- 再在代码中新建个菜单,把该菜单绑定到上面的 Action 中:
QMenu *menu = new QMenu(this);
menu->addAction(ui->actSelAll);
menu->addAction(ui->actSelNone);
menu->addAction(ui->actSelInvs);
ui->actSelPopMenu->setMenu(menu);
- 最后把该 Action 添加到 ToolBar 上:
ui->toolBar->addAction(ui->actSelPopMenu);