QWebView ignores user style sheet

  • I'm trying to customize QWebView's scroll bars and can't get it done whatsoever. I've browsed the internet to come up with the following minimal example:

    #include <QApplication>
    #include <QWebView>
    int main(int argc, char** argv)
      QApplication app( argc, argv );
      QWebSettings *settings = QWebSettings::globalSettings( );
      settings->setUserStyleSheetUrl( QUrl::fromLocalFile( "C:\style.css" ) );
      QWebView web_view;
      web_view.setUrl( QUrl( "http://www.google.de" ) );
      web_view.show( );
      app.exec( );
      return 0;

    style.css contains:

    ::-webkit-scrollbar {
        width: 5px;

    but the scroll bars don't change at all. I'm running Qt 5.5 (also tested 5.3.1) on Win10 but the scroll bars don't change at all. What am I doing wrong?

  • Hi! You got a typo here: QUrl::fromLocalFile( "C:\style.css" ).

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.