PDA

View Full Version : How to draw a semi circle or arc of ellipse



parnedo
1st July 2009, 15:26
Hi i'm getting crazy looking how to draw an arc of circle or arc of ellipse but without connecting the actual position with the start of the circle.

I'm using QPainterPath and the function arcTo. But arcTo adds a line from the origin to the begin of the curve.

instead of :
__
\__/

I want

\__/

Without the line (radious)

How can i make only a curve ??

Thanks

wysota
1st July 2009, 15:40
I'd say you should use QPainterPath::arcMoveTo().

parnedo
2nd July 2009, 02:39
Thank you.
I less a little example for other people



#include <QApplication>
#include <QGraphicsEllipseItem>
#include <QGraphicsScene>
#include <QGraphicsView>

int main( int argc, char **argv )
{
QApplication app(argc, argv);
QGraphicsScene scene;

scene.setSceneRect( -100.0, -100.0, 200.0, 200.0 );

QPainterPath* path = new QPainterPath();
path->arcMoveTo(0,0,50,50,20);
path->arcTo(0,0,50,50,20, 90);

scene.addPath(*path);

QGraphicsView view( &scene );
view.show();
return app.exec();
}