PDA

View Full Version : Re-implementing mouse event handlers while retaining its original functionality??



chaltier
21st March 2012, 06:24
Hello I am new to QT programming and have some questions i would like to ask..

I have implemented my own Graphics Scene and has its mouse event handler re-implemented..

Problem now is, when i add a new graphics item to the scene and set flag to movable, I am not able to move it..

If i take away the implemented mouse event handler, I can start moving the graphics item freely again..

How do I re-implement my mouse handler while retaining its original functionality?

Thanks alot..

ChrisW67
21st March 2012, 06:30
Call the parent class mouse event handler for any action you are not handling differently (standard C++ stuff):


void mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) {
if (event is of interest to me) {
//do something with it
// accept() or ignore() the event
}
else
QGraphicsScene::mousePressEvent(mouseEvent);
}

chaltier
21st March 2012, 06:31
nvm guys, i solved it

Just add this to the end of the implemented functions.. =D

QGraphicsView::mousePressEvent(e);