Using QWebEngine to render an image

风格不统一 提交于 2019-12-04 03:20:14

I just had the same problem, I solved it by showing the QWebEngineView after the load.

Here is the example that helped me : http://doc.qt.io/qt-5/qwebengineview.html#details

QWebEngineView *view = new QWebEngineView(parent);
view->load(QUrl("http://qt-project.org/"));
view->show();

I hope it will help you

So the answer from @wlalele helped, you do need to call view->show(), but that wasn't the only issue. In the end I had to inherit from QWebEngineView and override the event filter to monitor for update requests..

bool CustomWebEngine::eventFilter(QObject* object, QEvent* event)
{
    if (event->type() == QEvent::UpdateRequest)
    {
        emit updateFinished();
    }
}

Only after an UpdateRequest event has been received are you guaranteed to have access to the page in the view()->render function.

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