Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Scroll bar of QTextBrowser loses colors after focussing?

Scroll bar of QTextBrowser loses colors after focussing?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 468 Views
  • 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.
  • R Offline
    R Offline
    Robert Hairgrove
    wrote on last edited by Robert Hairgrove
    #1

    I have set the stylesheet of my QTextBrowser widget to background-color:white. autoFillBackground is set to true. It is the child widget of a QFrame and placed in a grid layout so that all but the frame's margin (approx. 2 pixels) is covered. When the text browser has the focus, the background color of the QFrame is changed to green by setting the stylesheet property; when it loses focus, it is reset to the normal light-gray color.

    When the main window containing these widgets is first opened, the scroll bars of the text browser are shown with their normal colors (see screenshot attached:
    scroll_bars_normal.png: scroll_bars_normal.png

    But after the browser is focussed once, they turn white, even though I have not changed the stylesheet of the text browser (see screenshot
    scroll_bars_after_focus.png:scroll_bars_after_focus.png

    What is going on here?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      And you used the QTextBrowser as selector in the stylesheet and not
      QWidget or similar ?

      R 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        And you used the QTextBrowser as selector in the stylesheet and not
        QWidget or similar ?

        R Offline
        R Offline
        Robert Hairgrove
        wrote on last edited by
        #3

        @mrjj I set the background-color for the QFrame widget (which is the parent of the text browser) when the text browser acquires the focus. But according to the documentation, stylesheets should not propagate to the children, as palettes do (if I understand this correctly, which I probably don't). And the text browser has its own style sheet which also merely has background-color:white; as the content.

        mrjjM 1 Reply Last reply
        0
        • R Robert Hairgrove

          @mrjj I set the background-color for the QFrame widget (which is the parent of the text browser) when the text browser acquires the focus. But according to the documentation, stylesheets should not propagate to the children, as palettes do (if I understand this correctly, which I probably don't). And the text browser has its own style sheet which also merely has background-color:white; as the content.

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @Robert-Hairgrove
          Oh but stylesheets do propagate.
          If the selector matches, then any children will be affected.
          Just try
          QWidget {
          background-color:white;
          }
          on a parent and all children will be colored.

          R 1 Reply Last reply
          2
          • mrjjM mrjj

            @Robert-Hairgrove
            Oh but stylesheets do propagate.
            If the selector matches, then any children will be affected.
            Just try
            QWidget {
            background-color:white;
            }
            on a parent and all children will be colored.

            R Offline
            R Offline
            Robert Hairgrove
            wrote on last edited by
            #5

            @mrjj Thank you, this is stated very clearly at the top of the documentation about "Qt Style Sheets", but I seem to have overlooked it.

            The problem was that I had set some things in Qt Designer and weird things were happening with the palettes as well. So I deleted all of the style sheets I had set and made sure that the palette properties all said "inherited".

            Now everything is working properly!

            1 Reply Last reply
            2
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi
              Super.
              Often one stylesheet is used and only set on the application.
              So it affects all it children and much easier to manage as its just one sheet.
              Mixing palette and stylesheet can also sometimes do strange stuff.
              At least it did for me.

              1 Reply Last reply
              1

              • Login

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