Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 942459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:16:32+00:00 2026-05-15T22:16:32+00:00

Using Qt stylesheets, is it possible to set a different background colour for each

  • 0

Using Qt stylesheets, is it possible to set a different background colour for each tab in a QTabBar that has 4 or more tabs?

My Qt application has 6 tabs underneath the menu bar. I’d like to change their background colours to 6 different colours using stylesheets.

2 issues appear to be standing in my way:

  • I can only style the “first”, “middle”, and “last” tabs using pure stylesheet syntax (hence why I say “4 or more” tabs).

  • I don’t think the individual tabs are child widgets of the QTabBar that I can access. The idea being that I could then attach a property to each child tab that I could reference in the stylesheet.

For example:

// Stylesheet
QTabBar::tab[index="3"] {
   background: blue;
}

// Code
QTabBar* bar = new QTabBar;
int index = bar->addTab("Tab 1");
QWidget* tab1; //= ????
tab1->setProperty("index", index);

Any help would be much appreciated. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:16:33+00:00Added an answer on May 15, 2026 at 10:16 pm

    The individual tabs are structs rather than objects. These structs are then used on painting. See the Qt source for more details.

    I’ve had an experiment with this and I can’t find a way to access a direct index, like you indicated. For your reference, I tried using properties such as the text, toolTip, whatsThis but couldn’t access any of them from the stylesheets, unfortunately.

    I’m afraid I don’t think what you want to do is possible without subclassing and modifying the paint events yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to set the media attribute on a link tag using the
Is it possible (using jQuery or otherwise) to set the style of a certain
I have tried using CSS to set the position of the background and the
Is it possible to manipulate the placeholders so that I can not only set
I'm trying to use the simplest possible scenario using a date picker in different
I am styling a web application that I made with Java EE (using JSF
I currently am using two stylesheets to get my intended output. The first stylesheet
In a xslt-stylesheet I'm using the methods exsl:node-set and set:distinct to access and filter
IIS7 supports this by using <system.webServer> configuration element to set module's preCondition=managedHandler attribute. Since
I have several stylesheets. The first one is a stylesheet with some styles that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.