PDA

View Full Version : QPainterPath -



aguleo
17th February 2013, 12:42
Hi

Why do i loose fill color after the connectPath?



QPainterPath path;
path.moveTo(100, 100);
path.lineTo(100, 200);
path.lineTo(200, 200);
path.lineTo(200, 100);
path.connectPath(path);

wysota
17th February 2013, 13:54
Because as a result you get a path equivalent to:


QPainterPath path;
path.moveTo(100, 100);
path.lineTo(100, 200);
path.lineTo(200, 200);
path.lineTo(200, 100);
path.lineTo(100,100);
path.lineTo(100, 200);
path.lineTo(200, 200);
path.lineTo(200, 100);
which is not closed.

What you probably want is this:


QPainterPath path;
path.moveTo(100, 100);
path.lineTo(100, 200);
path.lineTo(200, 200);
path.lineTo(200, 100);
path.closeSubpath();

aguleo
17th February 2013, 15:53
Yeah ... yu read my mind ;)
Now i have a square.

wysota
17th February 2013, 16:26
Yeah ... yu read my mind ;)
Now i have a square.

BTW.

QPainterPath p;
p.addRect(100,100, 100,100);

aguleo
17th February 2013, 16:47
I know ... just exploring how to close a path.

I was reading this: http://qt-project.org/doc/qt-4.8/qpainterpath.html#cubicTo

The square was the simplest example that came o my mind.