【发布时间】:2018-02-19 06:17:35
【问题描述】:
我使用的是 qt 5.6.2。我想在网页上截屏。这是我正在使用的代码:
#include <QtWidgets/QApplication>
#include <QtWebEngineWidgets/QWebEngineView>
int main(int argc, char *argv[]){
int left, top, width, height;
left = 0;
top = 0;
width = 600;
height = 800;
QApplication a(argc, argv);
QWebEngineView* w = new QWebEngineView();
QImage image(height, width, QImage::Format_RGB32);
QRegion rg(left, top, width, height);
QPainter painter(&image);
w->page()->load(QUrl("https://www.yahoo.com"));
w->show();
w->page()->view()->render(&painter, QPoint(), rg);
painter.end();
image.save("test.png", "PNG", 80);
return a.exec();
}
我运行程序,弹出一个窗口,可以看到yahoo的内容。然后我将结果保存到test.png,但那是一张白色的图片。是我无法将结果保存到image 还是我无法将结果从image 保存到文件test.png 以及如何解决?
【问题讨论】:
标签: qt qwebengineview