PDA

View Full Version : Adding events to GraphicsView



mkarakaplan
2nd May 2009, 13:32
Hi all,
I work with qtdesigner. I created windows with a graphicsview. I could add graphic items to scene. Now i want to add mouse release event to this graphicsview.

void MainWindow::mouseReleaseEvent(QMouseEvent *event)
{
printf("Mouse released\n");
QGraphicsView::mouseReleaseEvent(event);
}

But it doesnt work. How can i do that in simple way.

olidem
2nd May 2009, 14:04
No.
Subclass QGraphicsView and override the necessary funtions there.
Note that you can also subclass the items themselves and react fro mouse actions already there

mkarakaplan
2nd May 2009, 14:24
I need a simple example.

Lykurg
2nd May 2009, 14:59
I need a simple example.

Yeah, of course, but before could you please
Use the [ CODE ] tags that your example code is shown probably
Use the Newbie forum for questions that sort of
Tell us what you want to achieve once you get the release event, because I guess you don't need all this...

aamer4yu
3rd May 2009, 12:03
QWidget is an ancestor of graphics view. So you get mouseReleaseEvent in graphics view. You just need to override the function QAbstractScrollArea::mouseReleaseEvent

mkarakaplan
3rd May 2009, 22:53
I wrote here., but no one helped. During all day i tried a lot.

http://www.qtcentre.org/forum/f-newbie-4/t-adding-events-to-graphicsview-created-with-designer-20724.html/?highlight=scene

lni
4th May 2009, 00:26
I wrote here., but no one helped. During all day i tried a lot.

http://www.qtcentre.org/forum/f-newbie-4/t-adding-events-to-graphicsview-created-with-designer-20724.html/?highlight=scene

You derive from QGraphicsView, but the constructor takes another QGraphicsView, and your scene is using that view....