Mouse press event issues

Jeff Mitchell kde-dev at emailgoeshere.com
Wed Jul 2 21:56:32 CEST 2008


William Viana wrote:
> Hi there,
> 
> Some of you may have noticed that in zoomed out CV when you click in
> the first containment the applet browser pops out but nothing happens
> when you click in the other ones. It seems that the mouse press event
> is not being triggered for those containments unless you click in an
> applet inside that containment (in some cases only in the applet
> header).
> 
> At first I thought it was a coordinates issue so I created a
> mousePressEvent function in ContextView to see what happens.
> 
> From [ http://doc.trolltech.com/4.4/graphicsview.html ]:
> 
> "[...] For example, when you click your mouse in QGraphicsView's
> viewport, you can ask the scene what item is under the cursor by
> calling QGraphicsView::mapToScene(), followed by
> QGraphicsScene::itemAt() "
> 
> So this is basically what I did in ContextView::mousePressEvent but I
> keep receiving my debug message "OUTside item" when I click in other
> containments.
> 
> If you have some ideas/clues of what's going on please help. I might
> have not understood the documentation well...

I'm not really sure, but I do know that things never seem to work as 
they're supposed to.  For instance, calling setAcceptDrops isn't enough 
on a view, you have to also be implementing mouseEnter and mouseLeave 
and be accepting those events.  Or something along those lines.  Point 
is, it's not straightforward.

Try not doing the maptToScene followed by itemAt.  I've had success in 
the PUD just doing, (from within my QGV):

QGraphicsItem* item = itemAt( event->pos() );

I don't really see the point in mapping to the scene when the view does 
itemAt all on its own...

--Jeff


More information about the Amarok-devel mailing list