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. avoiding styleSheet inheritance
Forum Updated to NodeBB v4.3 + New Features

avoiding styleSheet inheritance

Scheduled Pinned Locked Moved Unsolved General and Desktop
stylesheet
3 Posts 3 Posters 5.6k 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.
  • F Offline
    F Offline
    fp615
    wrote on last edited by
    #1

    I'm applying styles to some widgets. I have 3 "boxes", created with a QWidget each, and I want them to have rounded corners and a different background color.

    Inside each one, I need to have different widgets, and I'm using layouts for this.

    It happens that all the children of one QWidget inherit the parent styles.
    For example I use:
    widget->setStylesheet( "background-color: #edcba9; border-radius: 10px;")

    Is it possible to set a styleSheet that has no effects on children objects?

    I have some other style-related problems but I think they are all related to inheritance, for example I need to specify new style for QToolButtons since they lose any animation (hover, pressed, etc) when children of a styled widget.

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

      Hi,

      You can use e.g. an id selector for that

      Hope it helps

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

      redtideR 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        You can use e.g. an id selector for that

        Hope it helps

        redtideR Offline
        redtideR Offline
        redtide
        wrote on last edited by
        #3

        FWIW this could be marked ad solved, I had the same issue and solved by setting something like:

        setStylesheet("#MainWindow{background-color:#000000;color:#ffffff};}")
        
        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