12

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

Shf
  • 3,463
  • 2
  • 26
  • 42
  • As far as I can tell, Chromium handles drawing the scrollbars and you'd have to make a custom build of WebEngine if you wanted to modify them in any way. – MrEricSir Sep 16 '15 at 17:17

2 Answers2

10

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

See QWebEngineSettings::WebAttribute

MagicKyle
  • 366
  • 3
  • 9
8

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.

Shf
  • 3,463
  • 2
  • 26
  • 42
  • @OzanYukruk I modified webpage itself (i have access to it's code.) To do this through Webengine - it has method that gets you plain text of html source code. Correct style tag and load modified page i guess – Shf Jul 15 '16 at 12:05
  • Oh okay, I'm just requesting websites that I don't have access to. So It seems I won't be able to hide the scrollbar – OzanYukruk Jul 15 '16 at 12:07
  • 6
    m_webView>page()>runJavaScript("document.body.style.overflow='hidden';"); this did the trick. – OzanYukruk Jul 15 '16 at 12:44