Make QGraphicsItem not moveable in QGraphicsScene
I'm trying to make the qgraphicsitem not moveable. I tried setting the flag when its being clicked and tried setting it when the item is created etc. I can call flags(); and it shows that ItemIsMovable is not in the flags list yet it is still able to be moved. I have noticed when I pop up a modeless dialog in my mainwindow.cpp then go back to the mainwindow without closing the dialog and try to move an item it then recognizes the flag and I can't move the item until I close the dialog. I'm not sure why qgraphicsscene is ignoring the flag. Can anyone please explain how I can get this to work?
Here is some of my code stripped down to the relevant stuff.
Code:
//GraphScene.h
{
private:
protected:
};
//GraphScene.cpp
{
x = qgraphicsitem_cast<QGraphicsItem*>(itemAt(event->scenePos(), QTransform()));
if (x)
{
}
}
//y.h
class y : public QGraphicsObject
{
protected:
};
//y.cpp
y::y()
{
setFlags(ItemIsSelectable | ItemIsFocusable);
setAcceptHoverEvents(true);
}
{
update();
}
Re: Make QGraphicsItem not moveable in QGraphicsScene
Please provide a minimum compilable example reproducing the problem.