依据圆盘,在圆盘里面画12个有等间距的相同的等腰小梯形
时间: 2024-04-05 15:32:29 浏览: 19
好的,您可以使用以下代码在圆盘里面画12个等间距的相同的等腰小梯形:
void QDiscWidget::draw_disc_scale(QPainter &p) {
p.save();
QPen pen(QColor(255, 255, 255));
pen.setWidth(5);
p.setPen(pen);
float angle = 30;
float edgeLen = 15;
float halfWidth = 3;
for (int i = 0; i < 12; ++i) {
QPolygonF polygon;
polygon << QPointF(disc_R - halfWidth - edgeLen, 0)
<< QPointF(disc_R - halfWidth, 0)
<< QPointF(disc_R - halfWidth, -edgeLen)
<< QPointF(disc_R - halfWidth - edgeLen * qSin(qDegreesToRadians(angle / 2)), -edgeLen);
p.drawPolygon(polygon);
p.rotate(30);
}
p.restore();
}
这段代码会在圆盘上等间距地绘制12个等腰小梯形,每个小梯形之间相隔30度,梯形的顶点分别为(disc_R - halfWidth - edgeLen, 0),(disc_R - halfWidth, 0),(disc_R - halfWidth, -edgeLen),(disc_R - halfWidth - edgeLen * qSin(qDegreesToRadians(angle / 2)), -edgeLen)。其中,angle为小梯形两边夹角的度数,edgeLen为小梯形两边的长度,halfWidth为小梯形上底边的一半长度。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)