哈哈,正好做过这个,便宜你了,研究好长时间啊
void drawArc(QPainter *painter,int lx,int ty,int rx,int by,int sx,int sy,int ex,int ey)
{
if(painter == NULL)
return;
int cx = abs(lx + rx)/2;
int cy = abs(ty + by)/2;
float start = atan2(float(cy - sy),float(sx - cx));
float end = atan2(float(cy - ey),float(ex - cx));
start = start * 360 / (3.1415926 *2) *16;
end = end * 360 / (3.1415926 *2) *16;
if(start < 0)
start += 5760;
if(end < 0){
end += 5760;
}
end -= start;
if(end < 0){
end += 5760;
}
painter->drawArc(QRectF(lx,ty,rx - lx,by - ty),start,end);
}