PDA

View Full Version : Image with on top widgets



^NyAw^
24th October 2017, 09:07
Hi,

I would like to show an image that have to have widgets on top of it. Think on a image that shows a paper and 2 lineedits that show the dimensions of the paper.

What I want to do is what SCADA systems do. It shows a representation of a machine and some widgets ont top of the image that show information and let the user change them.

Which is the best approach to do this?
Using a QGraphicsView? What about the position of the widgets when the view is reseized?

Thank you,

d_stranz
24th October 2017, 17:22
QGraphicsView would probably work for this. I would create a QGraphicsPixmapItem that contains your image. I would then add the line edits as children of this pixmap item so that they scale and translate according to the coordinates of the pixmap, not the coordinates of the scene.

If you add all three items as children of the main scene, then they are independent as far as scaling and translation are concerned. Adding the line edits as children of the pixmap ensures they move and scale with it. If you want the line edits to stay the same size regardless of the size of the pixmap, then set the QGraphicsItem::ItemIgnoresTransformations flag for them. They will still move, but will stay the same size.