PDA

View Full Version : Problem with QPainterPath



kaktus123
7th August 2012, 12:10
I used QPainterPath to create a polygon.


QPainterPath path;
path.addEllipse(0, 0, 50, 50);
path.closeSubpath();
qDebug() << path.currentPosition();

path.moveTo(25, 25);
path.lineTo(25, 40);

m_polygon = path.toFillPolygon();


I want see line in my ellipse, but it seems than method closeSubpath() don't put currentPosition to (0, 0) and qDebug tell me that too. I want draw my line in ellipse without line that move from ellipse to start point of this inner line. Any ideas? Thank you for help!

Added after 1 36 minutes:

Even I use QPainterPath Class Reference example I see line from (20, 20) to (0, 0). It seems that path.moveTo(0, 0) draw line.


QPainterPath path;
path.addRect(20, 20, 60, 60);

path.moveTo(0, 0);
path.cubicTo(99, 0, 50, 50, 99, 99);
path.cubicTo(0, 99, 50, 50, 0, 0);

QPainter painter(this);
painter.fillRect(0, 0, 100, 100, Qt::white);
painter.setPen(QPen(QColor(79, 106, 25), 1, Qt::SolidLine,
Qt::FlatCap, Qt::MiterJoin));
painter.setBrush(QColor(122, 163, 39));

painter.drawPath(path);