The only way I've thought of achieving this is by obtaining the path and modifying all its items. Something like:
for(int i = 0; i < p.elementCount()-1; i++)
{
auto e = p.elementAt(i+1);
p.setElementPositionAt(i, e.x(), e.y());
}
p.moveTo(newpoint);
item->setPath(p);
QPainterPath p = item->path();
for(int i = 0; i < p.elementCount()-1; i++)
{
auto e = p.elementAt(i+1);
p.setElementPositionAt(i, e.x(), e.y());
}
p.moveTo(newpoint);
item->setPath(p);
To copy to clipboard, switch view to plain text mode
But it's kind of lame to do it like this. If only there was the possibility of deleting the first or last item we could do it too.
Since I haven't found any documentation on how to do this and a few posts asking similar things without answer I'm considering building the path myself by storing a vector of lines, but i guess that would be costly too. Any help is appreciated. Is there a way to access the internal vector of the path?
Bookmarks