Owner-draw QGraphicsItem Problem
-
Hi,
I have to draw a custom graphics item on QGraphicsView, but the problem is APIs of QPainter are not sufficient for me to draw the item. So I create a QPixmap which is as large as the viewport, and draw my item on the QPixmap, then draw the QPixmap by calling QPainter::drawPixmap(). But this way is inefficient and need much more memory.
Is there any way to improve? Can I get the pixel buffer of the QGraphicsView and draw on it directly when QGraphicsItem::paint() is called?
BTW: I use raster graphics engine.
Thank you!
-
Dashi,
what is missing in the QPainter API? And how do you paint on the QPixmap then? Afaik, you can't access the pixel buffer directly.
-
Hi Gerolf,
I have some 2d NURBS curves, what I need to do is draw those curves, and fill the area enclosed. I have a function to calculate the color of each pixel in the area to be filled, so I cannot use QBrush directly.
Thanks!
-
You need to use QImage to draw on pixel level.
-
and the pixmap / image could be of the size of the graphics item, needn't be of graphics view
-
Hi Andre and Gerolf, thank you both!
But the problem is: If the view is zoomed in, the item itself may be much bigger than the view...
-
And that is a problem because...?
3/7