ich habe eine Klasse abgeleitet von QGraphicsScene. Beim mousePressEvent prüfe ich, ob die linke Maustaste gedrückt ist. Wenn ja, füge ich der Szene eine Ellipse an:
Code: Alles auswählen
void GraphScene::mousePressEvent( QGraphicsSceneMouseEvent * mouseEvent )
{
QPointF pt=mouseEvent->scenePos();
if(mouseEvent->button() == Qt::LeftButton)
{
printf("\n%lf\t%lf", pt.rx(), pt.ry());
QGraphicsEllipseItem *ell=addEllipse(pt.rx()-2.0, pt.ry()-2.0, 4.0, 4.0);
printf("\n%x: %s", ell, ell->isVisible() ? "vis" : "nonvis");
ell->setVisible(true);
}
Danke!
C.