How to take webpage screenshots using QWebEngineView without opening window

可紊 提交于 2019-12-24 14:18:21

问题


I'm looking for a way to take website screenshots with QWebEngineView. The main goal is to develop a headless screencapture application that runs in the background.

I've managed to get a minimal working example to work (see this for example). However, these examples require that the QWebEngineView widget is made visible, either with calls to QWebEngineView::show(), QWebEngineView::showMinimized() or even QWebEngineView::setVisible(true), to be able to take a screen capture of a website. As this results in opening a series of windows, this solution is less than perfect.

Does anyone know of a way to use QWebEngineView to take screenshots of websites without having windows popping open?


回答1:


The solution is rather easy: configure the QWebEngineView widget to not show onscreen by setting the Qt::WA_DontShowOnScreen attribute through a call to QWidget::setAttribute(Qt::WA_DontShowOnScreen).

http://doc.qt.io/qt-5/qt.html#WidgetAttribute-enum



来源:https://stackoverflow.com/questions/48166021/how-to-take-webpage-screenshots-using-qwebengineview-without-opening-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!