Hi,
I want to move an item, but only if I press the right mousebutton.
Can somebody tell me how to do this?
I've tried this:
{
pos=e->scenePos();
end=e->scenePos();
item = new EllipseItem(pos.x(), pos.y(),10,10);
item2 = new EllipseItem(end.x(), end.y(),10,10);
if(e->button() == Qt::LeftButton)
{
if(itemAt(pos))
else
{
addItem(item);
addItem(item2);
linie = new LineItem(item,item2);
addItem(linie);
}
}
if(e->button() == Qt::RightButton)
{
}
//this doesn't works
}
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
{
pos=e->scenePos();
end=e->scenePos();
item = new EllipseItem(pos.x(), pos.y(),10,10);
item2 = new EllipseItem(end.x(), end.y(),10,10);
if(e->button() == Qt::LeftButton)
{
if(itemAt(pos))
{ QGraphicsScene::mousePressEvent(e); }
else
{
addItem(item);
addItem(item2);
linie = new LineItem(item,item2);
addItem(linie);
}
}
if(e->button() == Qt::RightButton)
{
item->setFlags(QGraphicsItem::ItemIsMovable);
item2->setFlags(QGraphicsItem::ItemIsMovable);
}
//this doesn't works
}
To copy to clipboard, switch view to plain text mode
Bookmarks