I have a QPainterPath that contains several consecutive polygons of a path. Given a new polygon, I need to know if this intersects or not with the QPainterPath and in case of intersecting, keep that intersection in a QList. The code I got is the following, but I need to improve it because the intersected method of QPainterPath takes a long time. If I comment that line (I can not do it because I need it but I did it in order to see how it accelerates) it's terribly fast, but if I let it come down in performance. How can I optimize it or maybe there is another way to do it without QPainterPath ?. Thanks
QPainterPath aux;
aux.addPolygon(QPolygonF(QVector<QPointF>() << lastLine.p1() <<
QPointF(point.x()+nx, point.y()+ny) << QPointF(point.x()-nx, point.y()-ny) << lastLine.p2() << lastLine.p1()));
QPainterPath pathAux = path.intersected(aux);
if (!pathAux.isEmpty())
inters.append(pathAux);
Aux is a painterpath that serves as an auxiliary of the polygon that I assemble, in pathAux I leave the intersection of the Painterpath path and the aux. I check if there is an intersection and if there is one, I add it to the QList inters.