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. Stylesheets: Different background colors inside QTabBar

Stylesheets: Different background colors inside QTabBar

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.0k 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.
  • _ Offline
    _ Offline
    __Alex__
    wrote on last edited by
    #1

    Hello everyone,

    I have a QTabBar and I want to know if the following is possible:
    I rounded the corners of the tabs, using:

    border-top-left-radius: 10px;
    border-top-right-radius: 10px;

    Now that the corners are round, behind them appears the background color of the QTabWidget. I would however prefer to see the background color of the parent element. Is that possible?

    Cheers
    Alex

    raven-worxR 1 Reply Last reply
    0
    • _ __Alex__

      Hello everyone,

      I have a QTabBar and I want to know if the following is possible:
      I rounded the corners of the tabs, using:

      border-top-left-radius: 10px;
      border-top-right-radius: 10px;

      Now that the corners are round, behind them appears the background color of the QTabWidget. I would however prefer to see the background color of the parent element. Is that possible?

      Cheers
      Alex

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @__Alex__
      try QTabBar { background: transparent; }

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • _ Offline
        _ Offline
        __Alex__
        wrote on last edited by
        #3

        Unfortunately this didn't change anything. My stylesheets look like this:

        1. QMainWindow has
        QMainWindow {
        background: rgb(227,235,255);
        border: 2px solid rgb(0, 0, 0);
        }
        
        
        QTabBar::tab {
        background: rgb(200,210,235);
        border: 2px solid rgb(160, 170, 220);
        min-width: 64px;
        padding: 4px;
        border-top-left-radius: 10px;
        border-top-right-radius: 10px;
        
        }
        
        QTabBar { background: transparent; }
        
        QTabWidget::pane {
        border: 2px solid rgb(160, 170, 220);
        }
        
        
        QTabBar::tab:selected, QTabBar::tab:hover {
        	background: rgb(227,235,255)
        }
        
        1. QTabWidget has
        QWidget {
        background: rgb(200,210,235);
        }
        
        raven-worxR 1 Reply Last reply
        0
        • _ __Alex__

          Unfortunately this didn't change anything. My stylesheets look like this:

          1. QMainWindow has
          QMainWindow {
          background: rgb(227,235,255);
          border: 2px solid rgb(0, 0, 0);
          }
          
          
          QTabBar::tab {
          background: rgb(200,210,235);
          border: 2px solid rgb(160, 170, 220);
          min-width: 64px;
          padding: 4px;
          border-top-left-radius: 10px;
          border-top-right-radius: 10px;
          
          }
          
          QTabBar { background: transparent; }
          
          QTabWidget::pane {
          border: 2px solid rgb(160, 170, 220);
          }
          
          
          QTabBar::tab:selected, QTabBar::tab:hover {
          	background: rgb(227,235,255)
          }
          
          1. QTabWidget has
          QWidget {
          background: rgb(200,210,235);
          }
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @__Alex__ said in Stylesheets: Different background colors inside QTabBar:

          QTabBar::tab {
          background: rgb(200,210,235);
          border: 2px solid rgb(160, 170, 220);
          min-width: 64px;
          padding: 4px;
          border-top-left-radius: 10px;
          border-top-right-radius: 10px;

          }

          QTabBar { background: transparent; }

          These 2 definitions do what you intend to do. That's also what the docs say.
          I tried it with Qt 4.8 on Windows.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2
          • _ Offline
            _ Offline
            __Alex__
            wrote on last edited by
            #5

            Oh, I get it now! I should've put the "QTabBar { background: transparent; }" into the QTabWidget's stylesheet. Thanks!

            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