3

Example #1:

::-webkit-scrollbar-button {
    background-image: url(file:///tmp/bg.png);
}

Example #2:

::-webkit-scrollbar-button {
    background-image: url(qrc://bg.png);
}

Above examples are working only when QWebPage shows local html page. For http://stackoverflow.com it doesn't work. I've set the style using QWebSettings::setUserStyleSheetUrl() - it's a user style sheet.

user1180567
  • 175
  • 1
  • 2
  • 8

1 Answers1

1

You have to start Chrome (I'm assuming that's the browser you're using) with the command line flag --allow-file-access-from-files, or else it won't dynamically load local files (using the file:// protocol), as this could be a big security risk.

You can see http://code.google.com/p/chromium/issues/detail?id=4197&can=1&q=allow-file-access-from-files&colspec=ID%20Stars%20Pri%20Area%20Feature%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS for a complete history of this flag, why it behaves like this and why it#s implemented like this.

ramsesoriginal
  • 1,860
  • 1
  • 13
  • 16
  • I'm using Webkit through QWebKit. I can't find any informations about allow-file-access-from-files in Qt documentation. This works as expected: body { background-image: url(file:///tmp/bg.png); }, so it looks like this is enabled by default in QWebKit. – user1180567 Jan 31 '12 at 16:21
  • Yes, image starting with http:// will be loaded without problems. I've found QWebSettings::LocalContentCanAccessFileUrls in Qt documentation, and I can confirm - it is enabled by default. – user1180567 Feb 01 '12 at 13:27
  • Have you finally found why? – Maxbester Dec 17 '12 at 13:02
  • No, sadly, I have not :-( – ramsesoriginal Sep 06 '13 at 07:47
  • looks like the qrc reference is missing the third forward slash. – tiktok May 16 '15 at 09:52