View Full Version : Draw polygon with holes
crocpulsar
13th March 2009, 06:15
Hello,
I need to draw polygon with holes, the holes are also polygons, how do to build a graphics item like this in qt4?
I am thinking to construct it with QPainterPath, but I am not sure how to do it.
Any ideas?
janus
13th March 2009, 06:36
Hi,
not sure if this is the best solution, but I am doing something like this:
QPainterPath path;
QPolygonF p;
//add outer points
path.addPolygon(p);
QPainterPath inner;
//add inner points
inner.addPolygon(p);
path = path.subtracted(inner);
vratojr
13th March 2009, 10:19
Hi, It seemed to me that this version is faster:
QPainterPath path;
QRegion clip(path);
QPainterPath sub;
clip-=QRegion(sub);
paint.setClipRegion(clip);
paint.fillPath(path,brush);
crocpulsar
13th March 2009, 16:12
Thanks for these suggestions.
I will try them tomorrow and get back to here. I am just too drunk now.
Need to get some sleep
crocpulsar
14th March 2009, 06:31
Hi,
I think I will use the first method right now. If I need to write a customized graphics item, the second one may be a good choice.
BTW: is there any particular reason that the second method is faster than first one?
Thanks for help!:)
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.