# p03/ch05 — Qt 示例

## 可运行示例

| 目标 | 源文件 | 说明 |
|---|---|---|
| `dock_widget` | `dock_widget.cpp` | 构建运行见顶层 README；离屏验证 `QT_QPA_PLATFORM=offscreen tools/run_qt.sh dock_widget` |
| `central_widget` | `central_widget.cpp` | 构建运行见顶层 README；离屏验证 `QT_QPA_PLATFORM=offscreen tools/run_qt.sh central_widget` |

## 参考片段（签名/伪代码，未单独建目标）

### [block 0] .1 菜单栏

```cpp
QMenuBar *menuBar() const
```

### [block 1] .1 菜单栏

```cpp
QAction* addMenu(QMenu * menu)
QMenu* addMenu(const QString & title)
QMenu* addMenu(const QIcon & icon, const QString & title)
```

### [block 2] .1 菜单栏

```cpp
QAction* activeAction() const
QAction* addAction(const QString & text)
QAction* addAction(const QIcon & icon, const QString & text)
QAction* addAction(const QString & text, const QObject * receiver,
const char * member, const QKeySequence & shortcut = 0)
QAction* addAction(const QIcon & icon, const QString & text,
const QObject * receiver, const char * member,
const QKeySequence & shortcut = 0)
```

### [block 3] .3 状态栏

```cpp
//添加小部件
void addWidget(QWidget * widget, int stretch = 0)
//插入小部件
intinsertWidget(int index, QWidget * widget, int stretch = 0)
//删除小部件
void removeWidget(QWidget * widget)
```

### [block 6] .6 资源文件

```cpp
<RCC>
<qresource prefix="/images">
<file alias="doc-open">document-open.png</file>
</qresource>
<qresource prefix="/images/fr" lang="fr">
<file alias="doc-open">document-open-fr.png</file>
</qresource>
</RCC>
```

