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. QScrollArea background color
Qt 6.11 is out! See what's new in the release blog

QScrollArea background color

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 5.5k 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.
  • W Offline
    W Offline
    wavelike
    wrote on last edited by
    #1

    How can I keep the (background) color of a widget after it is placed inside QScrollArea?
    The application contains only two background colors (defined by the system), and I would like to keep it that way. But, when I introduce a QScrollArea, everything inside it gets painted in colors that are completely different from the rest of the application, which destroys the look.
    I tried setting the palette of the scroll area, setting its backgroundRole, and several other things I found on the internet, but nothing seems to work. All I can do is apply one of the three colors that QScrollArea offers, but they are completely different from what the rest of the application uses.

    Note: I don't want to play with styleSheets as I would have to do the same for every single widget inside the scroll area. All I would like to do is prevent the QScrollArea from changing the color of widgets inside it - just add the scroll bars and nothing else.

    Thanks.

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

      Hi,

      Can you post picture samples of what you are getting and what you are expecting ?

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

      W 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Can you post picture samples of what you are getting and what you are expecting ?

        W Offline
        W Offline
        wavelike
        wrote on last edited by wavelike
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Can you post picture samples of what you are getting and what you are expecting ?

          W Offline
          W Offline
          wavelike
          wrote on last edited by
          #4

          @SGaist

          I am not sure what the forum policy is when it comes to posting images, so here are the links:

          Preferred look: http://s13.postimg.org/5pysdlppj/color_Good_resized.jpg
          Obtained look: http://s16.postimg.org/6oh620o0l/color_Bad_resized.jpg

          Obtained look: Look at the left half of the window, there are two vertical tabs called Chooser and Adjuster. It's a QTabWidget and both tabs are QFrame. In the picture, Chooser is the active tab and it contains checkboxes, combo boxes etc. I need horizontal scrolling here, so there is a QScrollArea there and, in this picture, it draws everything inside it in white (QPalette::Base). If I try QPalette::AlternateBase or QPalette::Window, the background becomes dark - either similar to the color of the inactive tab or even darker, both being very bad choices for different reasons. What I want is shown in the preferred look image, which is without QScrollArea.

          I hope this helps.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            That's indeed a strange interaction. Can you reproduce that with a small set of widgets ?

            Also why put them in QFrames ? A QGroupBox would be a better fit for that.

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

            W 1 Reply Last reply
            0
            • SGaistS SGaist

              That's indeed a strange interaction. Can you reproduce that with a small set of widgets ?

              Also why put them in QFrames ? A QGroupBox would be a better fit for that.

              W Offline
              W Offline
              wavelike
              wrote on last edited by
              #6

              @SGaist

              I am not first to ask about this problem, but here it goes: http://s24.postimg.org/r6wo5opw5/scroll_Test.png
              It is a QTabWidget whose tab is a QFrame, which has a QScrollArea inside. As you can see, It is darker in color than the background of its parent QFrame.

              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