[SOLVED] How to filter out events from a QMDISubWindow when they go through a QGraphicsView
laura7s last edited by
I have a QMainWindow where the central widget is a QMDIArea. In this area I add QMIDSubWindows and to each sub window I add a QGraphicsView. In the QGraphicsView I handle mouse events in order to draw (left mouse click) or erase (right mouse click) and middle mouse pressed to zoom in/out. This all works fine. Initially, I had two QGraphicsView which I added to QGroupBox and all worked as expected. Now, I want to have flexibility in the number of QGraphicViews therefore I replaced the QGroupBoxes with QMDISubWindows.
Now the problem... Because of the QMDISubWindows the mouse press events result in resizing/moving the windows which I don't want to do. So I want to keep the behaviour for the mouse events on the QGraphicsView and then filter from the QGraphicsView these events and not let them be processed by the QMDISubWindow. Therefore, if the mouse events are at the border or title area of the window, they will still be processed by the QMDISubWindow but when they are in the central area where the QGraphicsView is then they will be filtered. Or at least that's what I thought could be a solution (any other ideas appreciated)...
This, I don't know how to do. I tried the installEventFilter and the blockSignals but it didn't work, possibly because I'm not sure where to install the event filter. I also tried to create my own QMDISubWindow class and override the mouse-related events but this is already rather complicated for my level of QT programming.
Is it possible to give me some direction on which is the most straight forward way to solve this problem?
- Is it through installEventFilter? In that case my event filter should be in the QMainWindow or the QGraphicsView?
- Or do I def. have to override the mouse events and create my own QMDISubWindow class?
Please let me know if code is required for this question. I haven't included any since both my QMainWindow and QGraphicsView classes are lengthy and I think not necessary helpful for my question.
Thank you in advance! (and sorry for the amount of text in this question :))
laura7s last edited by
Ok, I managed to solve this problem by adding the line:
at the end of the overridden Mouse[Pressed/Moved/Released]Event functions of my implementation of the QGraphicsView.