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. Confused about how style sheet inheritance works
Forum Updated to NodeBB v4.3 + New Features

Confused about how style sheet inheritance works

Scheduled Pinned Locked Moved Unsolved Qt WebKit
qt 4.8qwebviewstylesheetcss
5 Posts 3 Posters 2.4k Views 2 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.
  • D Offline
    D Offline
    define-qt
    wrote on 16 Jun 2018, 04:06 last edited by
    #1

    Scenario: I have a QMdiSubWindow with some minor padding and border styling applied to all widgets within it. I want to exempt a QWebView and it's child QWebPages from this styling.

    I can't apply style sheets directly to the QWebPages; I have applied them to the QWebView but strangely the pages still inherit styles from the sub-window instead.

    Applied to QMdiSubWindow:

    QWidget { padding: 1; border: 0; }
    

    How should I change this, or what should I apply to QWebView to solve the problem? I'm not a CSS expert so admittedly this might be something basic I'm overlooking.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 16 Jun 2018, 15:30 last edited by
      #2

      Hi,

      Be more precise with your style sheet. Yours basically say that all QWidgets should have the properties you set there.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply 16 Jun 2018, 23:07
      1
      • S SGaist
        16 Jun 2018, 15:30

        Hi,

        Be more precise with your style sheet. Yours basically say that all QWidgets should have the properties you set there.

        D Offline
        D Offline
        define-qt
        wrote on 16 Jun 2018, 23:07 last edited by
        #3

        @SGaist Except that is, effectively, what I want. Sure, I can be more granular when it comes to the stylesheet that is applied to QMdiSubWindow, but that won't work for many cases.

        Let's say I have this applied to QMdiSubWindow:

        QLineEdit { border: 0; }
        

        Then I have a QWebPage with a text entry form. For some reason, that text entry form appears with no border, even when I apply this to its parent QWebView:

        QLineEdit { border: 5; }
        

        So granularity is of course a good suggestion but it doesn't really solve my problem.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          define-qt
          wrote on 17 Jun 2018, 00:00 last edited by
          #4

          I resolved the immediate issue, by going more granular in the subwindow style sheet, figuring out and listing the widget classes I wanted to target without hitting every single QWidget. QWebView currently doesn't have any styling at all.

          Ultimately, I still don't understand how QWebView is applying its style sheets. If I tested something out like QLineEdit { border: 200; }, the form field would appear with its normal border. If I did * { border: 200; }, it would have no border.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            KillerSmath
            wrote on 17 Jun 2018, 05:50 last edited by
            #5

            @define-qt
            You can be more specific using the name of object as identifier in style sheet sintaxe

            QLineEdit#ObjectName { border:0; }
            

            @Computer Science Student - Brazil
            Web Developer and Researcher
            “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

            1 Reply Last reply
            2

            4/5

            17 Jun 2018, 00:00

            • Login

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