qt - Detecting Mouse Event over Multiple Graphics View -


I have a class "Seen window" that inherits QGraphicsScene. I have a mouse movement that emits the current X and Y position of the mouse on the scene.

In my main window class, I have four graphics vzes that I use to display different images. I have created four objects of the same graphics class to set on the scene. I want to know that my mouse from the graphics is currently watching how do I do it? I tried to use the event filter in the main category to detect the scene but it is not helping. I tried to do this in the following way:

  bool MainWindow :: eventFilter (QObject * f_object, QEvent * f_event) {if (f_object == Graphicsview & amp; amp; and f_event -> Type () == QEvent :: MouseMove {qDebug () & lt; & Lt; "I'm in scene 1"; }   

Can anyone please provide a solution to this?

Thank you.

* Receiving answers from comments ...

The problem is that you Install Event Filter on QGraphicsView , although instead of viewing the mouse, instead of looking at yourself, it was controlled by viewport , so to "catch" your event filter It needs to be installed on the mouse viewport:

  Graphics View-> Viewport () - & gt; InstallEventFilter (filter);    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -