In a Qt based application I'm developing I'm using a QGraphicsView to display sensor data in a 2D grid. On the side I'd like to show a legend/palette to relate the colours in the grid to values.
The user can zoom and pan the sensor data view, but understandably the palette should be stationary in the view. So placing the palette/legend in the sensor view scene requires some additional care: Applying the inverse user transformation.
However I'd rather have the palette/legend be implemented as kind of an (noninteractive) overlay layer with it's very own transformation. Is that somehow possible?
I think you should implement your legend/palette overlay out of the QGraphics context, if you move (setPosition...) of this item to invert the user transformation you item will be re-indexed in the graphic tree any time you pan/zoom ...
Doing an overlay widget is definitely doable, but in this case since it's part of you graphic context I would recommend to implement your own QGraphicsView
(wicth is a widget) re-implement the paintEvent
to paint you palette/legend in default widget space (no transformation). Plus if your palette/legend is static you can render it once in a pixmap and simply repaint this buffer pixmap anytime the QGraphicsView
needs an update (of course re-sizing will require the buffer to be updated ...).
If you do so no worry about the non-interacting part, you don't even have to forward events.