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. [Solved] QTabWidget, change tab's background-color
Forum Updated to NodeBB v4.3 + New Features

[Solved] QTabWidget, change tab's background-color

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 28.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.
  • X Offline
    X Offline
    xXDarkShadowXx
    wrote on last edited by
    #1

    How to change a QTabWidget's tab's background color?
    I've tried every single solutions found on Internet but nothing works.

    The closest I've got to actually changing the style of a tab is using this

    @ui->Wdgt_Inbox->tabBar()->setTabTextColor(0, "black");@

    Unfortunately, there's no setTabBackgroundColor option.

    @
    ui->Wdgt_Inbox->tabBar()->setCurrentIndex(0);

    ui->Wdgt_Inbox->tabBar()->setStyleSheet("background-color:cyan;");
    ui->Wdgt_Inbox->tabBar()->setStyleSheet("QWidget { background-color:cyan; }");
    ui->Tab_Inbox->setStyleSheet("background-color:cyan;");
    @

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You need to apply the style to the tabwidget itself, not the tab bar, and use a ::tab sub-control.
      Take a look "here":http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar for an example.

      1 Reply Last reply
      1
      • X Offline
        X Offline
        xXDarkShadowXx
        wrote on last edited by
        #3

        I've found something quite strange while playing around.

        When you change the QTabWidget's tabShape to triangular, your tabs inherit the QTabWidget's background color.

        And the good thing is, triangular tabs look even better than rounded ones.

        Now if only i could find a way to get rid of that awful white border around the QTabWidget I'd be in heaven.

        1 Reply Last reply
        0
        • X Offline
          X Offline
          xXDarkShadowXx
          wrote on last edited by
          #4

          [quote author="Chris Kawa" date="1382307057"]You need to apply the style to the tabwidget itself, not the tab bar, and use a ::tab sub-control.
          Take a look "here":http://qt-project.org/doc/qt-5.1/qtwidgets/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar for an example.[/quote]

          Oh, thanks.

          I didn't see your reply because we replied at the same time.

          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