PDA

View Full Version : Problem applying QGraphicsBlurEffect to a QGraphicsPixmapItem



ucomesdag
21st August 2010, 17:21
Hi all,

I try to apply blur to an image but nothing seems to happen and can't wrap my head arround whatmight be wrong here:


QPixmap buffer(image.size());
QGraphicsPixmapItem item(buffer);
QGraphicsBlurEffect effect;
effect.setBlurHints(QGraphicsBlurEffect::QualityHi nt);
effect.setBlurRadius(5);
item.setGraphicsEffect(&effect);

item.pixmap().toImage().save("blur.png");

Lykurg
21st August 2010, 23:21
Ehm, you are constructing an empty pixmap, and blur an empty pixmap results in an empty pixmap;) You might want to try
QPixmap buffer(image);

And also I think that the pixmap function of the item returns the unmodified source pixmap of the item. But I am not sure on that. So if you want save it you have to render the scene or set the pixmap to a label and render that back to a pixmap.

ucomesdag
22nd August 2010, 00:45
Nope it ain't an empty pixmap. But you hit a point, how could I render it as it's offscreen?

hobbyist
22nd August 2010, 09:23
You will probably have to add your item to a QGraphicsScene, which you can then render() off-screen using your own QPainter. See also QGraphicsView::render() for off-screen rendering and some examples related to printing.