|
楼主 |
发表于 2021-8-17 23:18:12
|
显示全部楼层
给表盘画上刻度,用到的函数是drawPie:
- QRadialGradient Radial(0, 0, getMaxDiameter() / 2, 0, 0);
- QRadialGradient RadialH(0, 0, getMaxDiameter() / 2, 0, 0);
- QRadialGradient RadialM(0, 0, getMaxDiameter() / 2, 0, 0);
- Radial.setColorAt(1, QColor::fromRgba(0xFF808080));
- Radial.setColorAt(0.98, QColor::fromRgba(0xFFE6E6E6));
- Radial.setColorAt(0.93, QColor::fromRgba(0xFFE6E6E6));
- Radial.setColorAt(0.91, QColor::fromRgba(0));
- Radial.setColorAt(0.00, QColor::fromRgba(0));
- p.setBrush(Radial);
- p.drawEllipse(-(getMaxDiameter() / 2), -(getMaxDiameter() / 2), getMaxDiameter(), getMaxDiameter());
- RadialM.setColorAt(1, QColor::fromRgba(0xFF808080));
- RadialM.setColorAt(0.98, QColor::fromRgba(0xFFA0A0A0));
- RadialM.setColorAt(0.96, QColor::fromRgba(0xFFA0A0A0));
- RadialM.setColorAt(0.95, QColor::fromRgba(0));
- RadialM.setColorAt(0.00, QColor::fromRgba(0));
- p.setBrush(RadialM);
- for (int i = 0; i < 120; ++i)
- {
- p.drawPie(-(getMaxDiameter() / 2), -(getMaxDiameter() / 2), getMaxDiameter(), getMaxDiameter(), 0 + i * 48, 8);
- }
- RadialH.setColorAt(1, QColor::fromRgba(0xFF808080));
- RadialH.setColorAt(0.98, QColor::fromRgba(0xFFA0A0A0));
- RadialH.setColorAt(0.93, QColor::fromRgba(0xFFA0A0A0));
- RadialH.setColorAt(0.92, QColor::fromRgba(0));
- RadialH.setColorAt(0.00, QColor::fromRgba(0));
- p.setBrush(RadialH);
- for (int i = 0; i < 24; ++i)
- {
- p.drawPie(-(getMaxDiameter() / 2), -(getMaxDiameter() / 2), getMaxDiameter(), getMaxDiameter(), 0 + i * 240, 16);
- }
复制代码
刻度盘的外观:
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|