加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – QT绘制一个圆圈

发布时间:2020-12-16 05:46:59 所属栏目:百科 来源:网络整理
导读:参见英文答案 draw a filled up circle2个 我正在学习QT,并且有一个简单的问题: 绘制半径为r且中心点为x,y的圆的最佳方法是什么? 谢谢! 解决方法 在paintEvent中使用: http://doc.qt.io/qt-4.8/qpainter.html#drawEllipse http://doc.qt.io/qt-4.8/qgrap
参见英文答案 > draw a filled up circle2个
我正在学习QT,并且有一个简单的问题:

绘制半径为r且中心点为x,y的圆的最佳方法是什么?

谢谢!

解决方法

在paintEvent中使用:

http://doc.qt.io/qt-4.8/qpainter.html#drawEllipse

http://doc.qt.io/qt-4.8/qgraphicsscene.html#addEllipse

在QGraphicsView / QGraphicsScene中使用此:

http://doc.qt.io/qt-4.8/qgraphicsellipseitem.html

http://doc.qt.io/qt-4.8/qpainter.html#drawEllipse

列出的最后一个链接是一个重载方法,允许您输入指定了两个半径的中心点.

void QPainter :: drawEllipse(const QPointF& center,qreal rx,qreal ry)

所以你的代码看起来像:

// inside MyWidget::paintEvent()
painter.drawEllipse(QPointF(x,y),radius,radius);

希望有所帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读