1 Attachment(s)
How to get size of pixmap in qgraphicsitem?
Hi,
I need to paint a red "X" over the image. For that I must get the size of the black rectangle on the screen but I could only get the size of the blue rectangle.
I tried using boundingRect(), viewport(), childrenRect() or similar but none of these worked.
Attachment 10524
Re: How to get size of pixmap in qgraphicsitem?
How is the image painted?
Is it its own graphics item?
Is it drawn as part of a larger item?
Cheers,
_
Re: How to get size of pixmap in qgraphicsitem?
There is a single QGraphicsPixmapItem in the scene with the pixmap of the head. On top of the view there is a transparent widget where I paint the red X.
Scene[0] -> GraphicsView1 -> Item[0] -> Pixmap (Head)
----------------------------> Overlay (X)
This pixmap is painted with scanLine and the red X with QPainter using the screen coordinates. The problem is that I couldn't get the right coordinates.
Re: How to get size of pixmap in qgraphicsitem?
Is the blue area part of the image or the view's background?
Do you need this to be in an overlay window or could you do it in the graphics scene?
Have you considered making the X a part of the image drawing?
Cheers,
_
Re: How to get size of pixmap in qgraphicsitem?
The blue area is the view's background. The problem with painting the X on the scene is that the view can have many items, one on top of the other. But still I need the X to be on top of everything.
Re: How to get size of pixmap in qgraphicsitem?
Re: How to get size of pixmap in qgraphicsitem?
What did you do with boundingRect() of the pixmap item that did not work? Post a code snippet or two.
Re: How to get size of pixmap in qgraphicsitem?
I tried drawForeground() and it worked great! Thanks!