Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, August 2007
Bug in QGraphicsView? Does not pass QMouseReleaseEvent properly


Message 1 in thread

I'm trying to get my QGraphicsView to pass a QMouseRelease event to 
items on the scene, but without any luck.  I'm doing it in the following 
way:

void myView::mouseReleaseEvent(QMouseEvent *event)
{
     ...
     qDebug() << "About to propogate event...";
     QGraphicsView::MouseReleaseEvent(event); <--This should propogate 
to the items right?
     ...
}

and in the items I do this...

void myGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
     qDebug() << "Success!";
     ...
}

However, this does not work.  I get the initial message from the 
graphics view, but nothing from the graphics item.  The really weird 
thing I discovered though is that if I pass the mouse release event as a 
MousePressEvent, that will be passed to the graphics item fine!  For 
example:

void myView::mouseReleaseEvent(QMouseEvent *event)
{
     ...
     qDebug() << "About to propogate event...";
     QGraphicsView::MousePressEvent(event); <--wtf?  Why does this work?
     ...
}

...and I can catch this fine in my graphics item by reimplementing 
mousePressEvent:

void myGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
     qDebug() << "Success!";
     ...
}

I have no idea what's going on, I think this is a bug in QGraphicsView 
or QGraphicsScene not propogating certain events correctly.  Does anyone 
else have a similar problem?  Thanks,
-Chris Portka

--
 [ signature omitted ] 

Message 2 in thread

Hi Chris,

This works for me and I am able to capture mouse release events.
I assume that
QGraphicsView::MouseReleaseEvent(event); 
is a typo and it is actually
QGraphicsView::mouseReleaseEvent(event); 

Maybe if you can provide a comiplable code I can look into it.. :)

R's
Prateek

-----Original Message-----
From: Chris Portka [mailto:cportka@xxxxxxxxxxxxxxx] 
Sent: Wednesday, August 15, 2007 5:42 AM
To: qt-interest@xxxxxxxxxxxxx
Subject: Bug in QGraphicsView? Does not pass QMouseReleaseEvent properly

I'm trying to get my QGraphicsView to pass a QMouseRelease event to
items on the scene, but without any luck.  I'm doing it in the following
way:

void myView::mouseReleaseEvent(QMouseEvent *event) {
     ...
     qDebug() << "About to propogate event...";
     QGraphicsView::MouseReleaseEvent(event); <--This should propogate
to the items right?
     ...
}

and in the items I do this...

void myGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
     qDebug() << "Success!";
     ...
}

However, this does not work.  I get the initial message from the
graphics view, but nothing from the graphics item.  The really weird
thing I discovered though is that if I pass the mouse release event as a
MousePressEvent, that will be passed to the graphics item fine!  For
example:

void myView::mouseReleaseEvent(QMouseEvent *event) {
     ...
     qDebug() << "About to propogate event...";
     QGraphicsView::MousePressEvent(event); <--wtf?  Why does this work?
     ...
}

...and I can catch this fine in my graphics item by reimplementing
mousePressEvent:

void myGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
     qDebug() << "Success!";
     ...
}

I have no idea what's going on, I think this is a bug in QGraphicsView
or QGraphicsScene not propogating certain events correctly.  Does anyone
else have a similar problem?  Thanks, -Chris Portka

--
 [ signature omitted ]