View Full Version : Qt 5: handling of CSS imports in QtHelp

14th January 2013, 16:33

I use QtHelp for my application’s help. It’s all very simple HTML and CSS code. In my help’s home page, I link a CSS file as follows:

<link href="res/stylesheet.css" rel="stylesheet" type="text/css"/>

Then, in my res/stylesheet.css file, I import another CSS file as follows:

@import "/doc/res/common.css";

/doc is the root folder for my application’s help and it’s how QtHelp (in Qt 4.8) used to require the import to be done (see this previous thread of mine (http://www.qtcentre.org/threads/47164-Problem-with-SDK-1-2-(Qt-4-8)-and-QtHelp)).

However, now, the above @import statement just doesn’t work, meaning that my application’s help doesn’t get styled anymore.

So, was I doing the right thing before and/or have things changed in Qt 5? What is certain is that if I include my CSS code directly in res/stylesheet.css, then everything is fine, telling me that the issue is with @import…

Anyway, any help would be much appreciated…

Cheers, Alan.

15th January 2013, 21:55
Qt5 now uses WebKit2, so it might be easiest to ask at the WebKit forum (ask about differences between WebKit1 and WebKit2).

15th January 2013, 23:20
Ensure the import is at the top of the file: see http://www.w3.org/TR/css3-cascade/#at-import

16th January 2013, 10:16
@wysota: sorry, I hadn't noticed that there is a WebKit forum on Qt Centre. I am going to ask there. Thanks.

@ChrisW67: yes, I am aware that imports should be at the top of a file and this is what I have. Yet, it doesn't work anymore as it used to.

21st January 2013, 17:49
Copy/paste of the solution I posted in the Qt Webkit sub-forum:

FWIW, I just came back to the above issue and found out what happened. Basically, the syntax changed (?) between Qt 4 and Qt 5. So, rather than having something like:

@import "/doc/res/common.css";
We should now have:

@import "qthelp://namespace/virtualFolder/doc/res/common.css";
Now, I wish it had been documented somewhere...