PDA

View Full Version : How do i propagate events from GraphicsView to Main Window?



chaltier
21st March 2012, 11:21
Example..

I have a text browser widget in my main window class..

I have re-implemented the mouse event handler for the graphicsView sub class..

Now, when i mouse click on my graphics view, i wan my text browser in main window class to display the x-y coordinates..

because the mouse press event is a function of the graphics view class, i could not access the text browser widget and pass the x-y coordinates to it..

how can i go about doing this??

Thankss..

Spitfire
21st March 2012, 13:44
In the event handler emit a signal (http://qt-project.org/doc/qt-4.8/signalsandslots.html)containing the coordinates and connect it to a slot that will update the text browser widget.

Or, you could install your text browser as an event filter of the graphics view. Then you need to implement eventFilter() (http://qt-project.org/doc/qt-4.8/qobject.html#eventFilter) method and you can see all the graphics view events inside your text browser.