# p03/ch10 — Qt 示例

## 可运行示例

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

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

### [block 1] .1 QPainter

```cpp
PaintedWidget::PaintedWidget(QWidget *parent) :
QWidget(parent)
{
resize(800, 600);
setWindowTitle(tr("Paint Demo"));
}
void PaintedWidget::paintEvent(QPaintEvent *)
{
QPainter painter(this);
painter.drawLine(80, 100, 650, 500);
painter.setPen(Qt::red);
painter.drawRect(10, 10, 100, 400);
painter.setPen(QPen(Qt::green, 5));
painter.setBrush(Qt::blue);
painter.drawEllipse(50, 150, 400, 200);
}
```

