Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED DIFFERENTLY] Overwrite the CSS style of a web page element
agarny last edited by
With Qt 4.8, I used to rely on the "@import" statement to import a CSS file into another, but for some (very annoying) reason it doesn't work anymore in Qt 5 (see "http://qt-project.org/forums/viewthread/23746/":http://qt-project.org/forums/viewthread/23746/). So, I thought I would do things differently, but now I am facing another unrelated issue.
Basically, my application's help is made of a series of HTML files which are styled using CSS. Those HTML files are used both on my application's website and within my application. In some HTML files, I have some code which I have styled in a certain way, the idea being not to show that code on my application's website while showing it within my application.
For this, I have a very simple CSS rule :
So, this means that by default (i.e. on my application's website), the code is not shown. Now, in my application, I want to see the code, so I thought I would use something like:
myLocalCssFile points to a file which has the following contents :
So, yes, some very simple code to show the code within my application. Yet, it doesn't work!
Interestingly (so to speak!), if I completely remove  and replace  with:
color: rgb(255, 0, 0);
Then, the code will be shown in all cases, except that within my application it will be in red.
So... it would seem that for (yet) some (more very annoying) reason, something is broken in Qt 5... or have I done something wrong. Hopefully, it's the latter...
Anyway, anyone any idea?
agarny last edited by
FWIW, I never managed to fix the above issue. However, I was originally using CSS imports in the Qt 4 version of my project. It's just that when porting it to Qt 5, the syntax changed and I couldn't find it, so I thought at the time I would try to get the same result using a different approach (which resulted in the issue above). Then, I managed to guess the correct syntax for CSS imports in Qt 5 ("http://qt-project.org/forums/viewthread/23746/":http://qt-project.org/forums/viewthread/23746/), so the above issue is not relevant to me anymore...