PDA

View Full Version : remove flags?



konvex
19th November 2008, 13:12
Hallo,
I have created an item in a GraphicsScene (item->setFlag(QGraphicsItem::ItemIsMovable) in the scene) and I have a subclass where I would draw a line when the item is selected (setFlag(QGraphicsItem::ItemIsSelectable) in the subclass) . But my problem is, that the item is movable and selected at the same time.
I would like that the item is not movable when I select it and draw the line....
How can I do this?

caduel
19th November 2008, 13:19
how about QGraphicsItem::setFlag(QGraphicsItem::ItemIsMovabl e, false)?

konvex
19th November 2008, 13:27
Thanks, but I've tried and it doesn't work :(
Is there another possibility?

caduel
19th November 2008, 13:48
you can
* try QGraphicsItem::setFlags(),
* dump the set QGraphicsItem::flags() to check that that flag is not set
* if it is still set: check your code for places where the flag might get set ;-)

konvex
19th November 2008, 15:01
Now I've tried this:
graphicsscene.cpp


void GraphicsScene::mousePressEvent(QGraphicsSceneMouse Event *e)
{
pos=e->scenePos();

EllipseItem *item = new EllipseItem(pos.x()-5, pos.y()-5,10,10);
item->setFlag(QGraphicsItem::ItemIsSelectable);
addItem(item);

if(item->isSelected())
{ item->setFlag(QGraphicsItem::ItemIsMovable, false); }
else
{ item->setFlag(QGraphicsItem::ItemIsMovable, true); }
}


but it doesn't work too....Can you tell me why?
It seems that the scene ignore item->setFlag(QGraphicsItem::ItemIsMovable, false).

Noroxus
18th March 2015, 03:26
made new thread