Qt QPainter 通过鼠标mousePressEvent事件得到起点坐标m_startPoint,通过mouseM

lognei2022-10-04 11:39:541条回答

Qt QPainter
通过鼠标mousePressEvent事件得到起点坐标m_startPoint,通过mouseMoveEvent事件得到终点坐标m_endPoint,通过起点坐标,终点坐标得到一个矩形.
qreal x = m_endPoint.rx() - m_startPoint.rx()
qreal y = m_endPoint.ry() - m_startPoint.ry()
qreal radius = qMin(x ,y );
怎么样以矩形中心(x/2,y/2)为圆点,以radius为半径画圆?
painter->drawEllipse(x/2,y/2 ,radius,radius) 怎么画不出来呢?
结果是什么都画不出!不甚感激!

已提交,审核后显示!提交回复

共1条回复
迷你红舞鞋 共回答了19个问题 | 采纳率94.7%
你不会看帮助手册?
void QPainter::drawEllipse ( int x,int y,int width,int height )
This is an overloaded function.
Draws the ellipse defined by the rectangle beginning at (x,y) with the given width and height.
1年前

相关推荐