PDA

View Full Version : How do I use QPixmap::grabWindow with offscreen (QScrollArea) regions ?



rsilva
24th April 2011, 03:24
How can I grab an entire window that is inside a scrollarea ?
My content inside it have more than 1600x1200.
The content is a flash app and I can scroll it, but want to grab the entire content to save it.
And QPixmap::grabWidget doesn't work too.

Lykurg
24th April 2011, 06:06
See QWidget::render(). There is also an example for your situation!

rsilva
24th April 2011, 14:14
I've tried it yesterday when I found it, but, it don't capture the Flash content in the WebView.


void Standalone::screenShot_VirtualScreen()
{
QImage img(ui->webView->page()->mainFrame()->contentsSize(), QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);

QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.setRenderHint(QPainter::TextAntialiasing, true);
painter.setRenderHint(QPainter::SmoothPixmapTransf orm, true);
ui->webView->render(&painter);
painter.end();

img.save(screenShotPath(), "PNG");
}


It's only give me a "empty" (background-color) image, and not the content.