Remove ScrollBars from QWebEngineView or QWebEnginePage

左心房为你撑大大i 提交于 2019-11-28 00:31:49

问题


Is there a way to remove scrollbars from QWebEngineView or can i somehow get access to it's ScrollArea?

With webkit it was as easy as

WebView->page()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAlwaysOff);
WebView->page()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAlwaysOff);

but i don't see any similar functionality within QWebEngine. I do not even see any scroll area within qwebengine sources.. Is there a something that i'm missing?

Update: I think i can try to force scrollbars disappear from some css settings that are passed with page for chromium


回答1:


Just set QWebEngineSettings::ShowScrollBars to false which is introduced in Qt 5.10

See QWebEngineSettings::WebAttribute




回答2:


Changing css style of the webpage worked. I've used

<style type="text/css">
body {
    overflow:hidden;
}
</style>

but bad luck for those, who do not have access for css of the webpage you are trying to show the way you want.



来源:https://stackoverflow.com/questions/32612478/remove-scrollbars-from-qwebengineview-or-qwebenginepage

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