Results 1 to 2 of 2

Thread: Overwrite the CSS style of a web page element

  1. #1
    Join Date
    Mar 2010
    Posts
    319
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 14 Times in 12 Posts

    Default Overwrite the CSS style of a web page element

    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://www.qtcentre.org/threads/5279...orts-in-QtHelp). 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]:

    Qt Code:
    1. span.myapp {
    2. display: none;
    3. }
    To copy to clipboard, switch view to plain text mode 
    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:

    Qt Code:
    1. myWebView->page()->settings()->setUserStyleSheetUrl(QUrl::fromLocalFile(myLocalCssFile));
    To copy to clipboard, switch view to plain text mode 
    myLocalCssFile points to a file which has the following contents [2]:

    Qt Code:
    1. span.myapp {
    2. display: inline;
    3. }
    To copy to clipboard, switch view to plain text mode 
    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:

    Qt Code:
    1. span.myapp {
    2. color: rgb(255, 0, 0);
    3. }
    To copy to clipboard, switch view to plain text mode 
    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.

  2. #2
    Join Date
    Mar 2010
    Posts
    319
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    1
    Thanked 14 Times in 12 Posts

    Default Re: Overwrite the CSS style of a web page element

    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://www.qtcentre.org/threads/5282...ht=#post236923), so the above issue is not relevant to me anymore...

Similar Threads

  1. Replies: 9
    Last Post: 23rd April 2012, 14:53
  2. overwrite pdf file
    By terhje in forum Newbie
    Replies: 2
    Last Post: 22nd February 2012, 13:41
  3. Replies: 1
    Last Post: 22nd September 2011, 02:39
  4. Overwrite Qt slot ...
    By jiapei100 in forum Qt Programming
    Replies: 1
    Last Post: 30th January 2010, 10:54
  5. Overwrite QKeyEvent
    By haldrik in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2008, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.