4

I'm trying to put two pictures in the QGraphicsScene. One is fixed and the other one is movable. But I succeed only in putting those pictures in the QGraphicsScene, I can't move them. How can I achieve this?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
prabhakaran
  • 5,126
  • 17
  • 71
  • 107
  • Items should be movable by default, how are you moving it? – cnebrera Jun 17 '10 at 15:43
  • I don't know why I can't move that. But it's moving now, after I applied the solution below. – prabhakaran Jun 17 '10 at 16:05
  • 1
    @cnebrera : actually, according to [the doc](http://doc.qt.nokia.com/4.6/qgraphicsitem.html#GraphicsItemFlag-enum), all flags are disabled by default. – Jérôme Jun 18 '10 at 07:51
  • @Jérôme I believe you, but I'm using tons of graphic items and moving them and doing dynamic slides and I have never had to set that flag to true. It is weird XD. – cnebrera Jun 18 '10 at 08:17
  • @cnebrera may be it is different in different versions. I am using 4.6(windows xp) – prabhakaran Jun 18 '10 at 14:49
  • @Jérôme I'm using 4.6 too, I will have another look at the code, now I really feel curious about it XD. – cnebrera Jun 19 '10 at 23:36

1 Answers1

8

You have to make sure the item is movable. Have a look at QGraphicsItem::setFlag.

You'll have to do something like this :

myImageItem->setFlag(QGraphicsItem::ItemIsMovable, true);
Jérôme
  • 26,567
  • 29
  • 98
  • 120