<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Baffling problems with setUserStyleSheetUrl]]></title><description><![CDATA[<p dir="auto">Hi. Sorry if this has been posted before but I've searched the web for hours with no luck.</p>
<p dir="auto">I'm having a completely baffling problem with setUserStyleSheetUrl. I'm trying to use a style sheet on the local machine, and generating the path using QFileInfo file("name.css") and QUrl::fromLocalFile(file.absoluteFilePath()). For some bizarre reason, if I use that the stylesheet is not picked up, but after random experiments on a Windows XP machine, I've found that if I reduce the number of leading slashes in the URI from 3 to 2 (file://C:/... instead of the file:///C:/... returned by fromLocalFile()), the stylesheet is picked up.</p>
<p dir="auto">This is clearly not right as QWebView::load() correctly finds local HTML files with the (correct) three slashes for a windows local URI.</p>
<p dir="auto">However, even once this "fix" is applied, I'm finding that tables are not rendering correctly. They render fine in webkit browsers such as Chrome, and they render fine in a QWebView when the stylesheet is embedded in the HTML in a style section, but when the css is loaded with setUserStyleSheetUrl, the borders and cellpadding instructions in the css seem to be ignored.</p>
<p dir="auto">I can't believe I am the only person to have had this problem but can find nothing even vaguely related on here or on the web generally so I guess I must be missing something. Could someone shed some light on a) why the file is not found using the unmodified URI returned by QUrl::fromLocalFile() and b) why the QWebView is rendering different results using setUserStyleSheetUrl() than when the css is just embedded in the HTML?</p>
<p dir="auto">Thanks in advance.</p>
]]></description><link>https://forum.qt.io/topic/8940/baffling-problems-with-setuserstylesheeturl</link><generator>RSS for Node</generator><lastBuildDate>Sun, 16 Aug 2026 07:34:17 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/8940.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 25 Aug 2011 21:51:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Baffling problems with setUserStyleSheetUrl on Fri, 26 Aug 2011 08:01:54 GMT]]></title><description><![CDATA[<p dir="auto">Well, loading the file and encoding it into base 64 then passing it as a data: object to setUserStyleSheetUrl works around the problem with actually locating the file, but the table rendering is still broken.</p>
<p dir="auto">I've tested this with third party CSS as well as my own and confirmed that the table is rendered correctly if I embed the CSS in the HTML with a style declaration.</p>
<p dir="auto">Can anyone explain why the rendering would be different using setUserStyleSheetUrl than when embedding the CSS with a style directive in the HTML?</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/post/106961</link><guid isPermaLink="true">https://forum.qt.io/post/106961</guid><dc:creator><![CDATA[Aardvajk]]></dc:creator><pubDate>Fri, 26 Aug 2011 08:01:54 GMT</pubDate></item><item><title><![CDATA[Reply to Baffling problems with setUserStyleSheetUrl on Fri, 26 Aug 2011 06:42:32 GMT]]></title><description><![CDATA[<p dir="auto">Thank you for the fast response, Andre. Thankfully we already have a default system for passing the CSS as base64 encoded string from a database and using an external file is just for testing CSS so less of a hassle than it may seem.</p>
<p dir="auto">Is this a known issue with setUserStyleSheetUrl? Your response surprises me given the maturity of the library and the activity level of bug fixing going on.</p>
]]></description><link>https://forum.qt.io/post/106930</link><guid isPermaLink="true">https://forum.qt.io/post/106930</guid><dc:creator><![CDATA[Aardvajk]]></dc:creator><pubDate>Fri, 26 Aug 2011 06:42:32 GMT</pubDate></item><item><title><![CDATA[Reply to Baffling problems with setUserStyleSheetUrl on Fri, 26 Aug 2011 06:14:55 GMT]]></title><description><![CDATA[<p dir="auto">Unfortunately, it does not seem to work that way. There is, however, a workaround. Just like you can with images, you can encode the style sheet file as base64, and then pass it directly. The ULR to generate looks like this:</p>
<p dir="auto">@<br />
data:text/css;base64,&lt;the actual base64 encoded file contents&gt;<br />
@</p>
<p dir="auto">I know, it is a hassle, but it does work...</p>
]]></description><link>https://forum.qt.io/post/106921</link><guid isPermaLink="true">https://forum.qt.io/post/106921</guid><dc:creator><![CDATA[andre]]></dc:creator><pubDate>Fri, 26 Aug 2011 06:14:55 GMT</pubDate></item></channel></rss>