Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. [SOLVED DIFFERENTLY] Overwrite the CSS style of a web page element
Forum Updated to NodeBB v4.3 + New Features

[SOLVED DIFFERENTLY] Overwrite the CSS style of a web page element

Scheduled Pinned Locked Moved Qt WebKit
2 Posts 1 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    Hi,

    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 [1]:

    @span.myapp {
    display: none;
    }@

    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:

    @myWebView->page()->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile(myLocalCssFile));@

    myLocalCssFile points to a file which has the following contents [2]:

    @span.myapp {
    display: inline;
    }@

    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 [1] and replace [2] with:

    @span.myapp {
    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?

    Cheers, Alan.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agarny
      wrote on last edited by
      #2

      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...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved