[PyQt] Newbie - QGraphicsItem & QGraphicsScene problems
ismail at namtrac.org
Tue May 13 18:51:16 BST 2008
On Tue, May 13, 2008 at 8:25 PM, Aysun Bascetincelik <aysunbcc at gmail.com> wrote:
> I am trying to implement a simple paint like program. I am having mainly two
> 1. I have an item class inherited from QGraphicsItem and I use
> QGraphicsScene.addItem() to add it to the scene. However, I can only see the
> last added item. Although all previous items (when I use
> QGraphicsScene.items()) are present and their visible properties are true,
> they are not shown on my scene. This thing only happens when I use addItem()
> with the class I implemented. If I use addLine() more than once, I can see
> all items created by that addLine() function.
Not sure about this one but,
> 2.The other problem is when I try to select an item with a left mouse click.
> I did not implement the mousePressEvent() inside the item class but I
> implemented the one in scene class. I can get the mouse scenePos() easily
> and use it to add items. After adding an item, if I use itemAt() function
> with a new click on the item and scenePos(), it always returns None. I set
> the flags of the item all true.
To be able to catch mouse events you need to call
QGraphicsView::setInteractive(True) on your graphics view object.
Never learn by your mistakes, if you do you may never dare to try again.
More information about the PyQt