0

This sounds like silly, but I cannot take a screenshot of a QwebView.

QImage image(view.page()->viewportSize(), QImage::Format_ARGB32);
QPainter painter;
painter.begin(image); // Here is the error. See below
view.page()->mainFrame()->render(&painter);
painter.end();
image.save("out.png");

And the error msg is,

mainwindow.cpp:115: error: no matching function for call to 'QPainter::begin(QImage&)'
candidate is bool QPainter::begin(QPaintDevice*)

What I know is ,QPaintDevice is the base of QPaint.

Dewsworld
  • 13,367
  • 23
  • 68
  • 104

2 Answers2

4

Looks from the error that you need to pass image by pointer:

painter.begin(&image);
Fraser
  • 74,704
  • 20
  • 238
  • 215
3

The error message told you: the method begin requires a pointer to a drawing surface, and not a reference. Try doing:

painter.begin(&image);
mtvec
  • 17,846
  • 5
  • 52
  • 83
Nola
  • 90
  • 2