[Qt-interest] Qpixmap::grabWidget format issue

Raphael Meloni raphael.meloni at gmail.com
Thu Jun 25 03:22:40 CEST 2009


You can try this.

 >     QPixmap pixmap = QPixmap::grabWidget(view);

       pixmap.save("test.png","PNG");
       qDebug() << pixmap.hasAlphaChannel();

 >     QImage image = pixmap.toImage();

chetan.jain at nokia.com escreveu:
> Hi,
> I have a QGraphicsView, with a QGraphicsPixmapItem that is showing a convoluted image (original image is Format_ARGB32_premultiplied format).
> For a specific scenario, I have to grab the entire view. But there is an ugly gray edge to the convoluted image when I do this.
> 
> I was using this code,
>     QPixmap pixmap = QPixmap::grabWidget(view);
>     QImage image = pixmap.toImage();
> 
> But at this point I find that the image is Format_RGB32 and I suspect that some of the alpha value was lost. 
> I tried widget.render(paintdevice, ....) instead, but still no luck.
> 
> I'm using a Win XP box.
> 
> Can anyone help with the same.
> BR
> Chetan



More information about the Qt-interest-old mailing list