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.
从错误中您需要通过指针传递image
:
painter.begin(&image);
The error message told you: the method begin
requires a pointer to a drawing surface, and not a reference. Try doing:
painter.begin(&image);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.