QT画圆 [英] QT drawing a circle
问题描述
我正在学习QT,并有一个简单的问题:
最好的方法是绘制一个圆的半径为r,中心点为x,
谢谢!
c> 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 QPointF&中心,qreal rx,qreal ry)
所以你的代码看起来像这样:
//在MyWidget :: paintEvent()
painter.drawEllipse(QPointF(x,y),radius,radius);
希望有帮助。
I'm learning QT, and had a quick question:
What would be the best way to draw a circle with radius r with the center point at x,y?
Thanks!
In a paintEvent
use this:
http://doc.qt.io/qt-4.8/qpainter.html#drawEllipse
http://doc.qt.io/qt-4.8/qgraphicsscene.html#addEllipse
In a QGraphicsView
/QGraphicsScene
use this:
http://doc.qt.io/qt-4.8/qgraphicsellipseitem.html
http://doc.qt.io/qt-4.8/qpainter.html#drawEllipse
The last link listed, is an overloaded method that allows you to enter the center point with the two radii specified.
void QPainter::drawEllipse ( const QPointF & center, qreal rx, qreal ry )
So your code would look something like:
// inside MyWidget::paintEvent()
painter.drawEllipse(QPointF(x,y), radius, radius);
Hope that helps.
这篇关于QT画圆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!