Hi,
i have a 4 vertices:
{
currentPen.setColor(Qt::blue);
currentPen.setWidth(3);
setPen(currentPen);
setAcceptsHoverEvents( true );
}
Vertex::Vertex(int x, int y) : QGraphicsEllipseItem(x-1,y-1,x+1,y+1)
{
QPen currentPen = pen();
currentPen.setColor(Qt::blue);
currentPen.setWidth(3);
setPen(currentPen);
setAcceptsHoverEvents( true );
setFlag( QGraphicsItem::ItemIsMovable, true );
setFlag( QGraphicsItem::ItemSendsScenePositionChanges, true );
}
To copy to clipboard, switch view to plain text mode
that describe a polygon (QGraphicsPathItem)
they are added to a QGraphicsScene in a QGraphicsView.
So far, everything's fine; i can move the the vertices around, hover effects and so on are working fine.
But now, i want to adjust the polygon if a user changes a vertex.
Is there any event the QGraphicsEllipseItem emits when moved?
Or does the QGraphicsScene have an event to tell me it's content hast changed?
i am looking for something like:
connect(m_scene, SIGNAL(changed()),
this, SLOT(updatePolygon()));
connect(m_scene, SIGNAL(changed()),
this, SLOT(updatePolygon()));
To copy to clipboard, switch view to plain text mode
or
Vertex* vertex = new Vertex(event->x(), event->y());
connect(vertex, SIGNAL(ItemPositionHasChanged()),
this, SLOT(updatePolygon()));
Vertex* vertex = new Vertex(event->x(), event->y());
connect(vertex, SIGNAL(ItemPositionHasChanged()),
this, SLOT(updatePolygon()));
To copy to clipboard, switch view to plain text mode
but both didn't work
Bookmarks