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 7989757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:50:14+00:00 2026-06-04T12:50:14+00:00

I have a QTabWidget that contains 4 tabs. I would like to style each

  • 0

I have a QTabWidget that contains 4 tabs. I would like to style each header of them individually : I saw I could use stylesheet to possibly do that. But my problem is that I couldn’t just change the header of one tab, where the name of the tab is, without changing the rest of the tab.

In a simple way, imagine I want to have the first tab red, the second blue, 3rd green and the 4th yellow. So, how can I change the style of every single tab without changing the others.

Thanks!

EDIT

I saw there how I could change the style of all tab headers at once, but not individually

  • 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-06-04T12:50:16+00:00Added an answer on June 4, 2026 at 12:50 pm

    If you subclass QTabWidget, you can access the protected function QTabWidget::tabBar(), which returns the QTabBar it uses. QTabBar has a method QTabBar::setTabTextColor() that will change the text color of an individual tab. Here is an example:

    #include <QtGui>
    
    class TabWidget : public QTabWidget
    {
    public:
        TabWidget()
        {
            addTab(new QPushButton("Hi 1!"), "Button 1 Tab");
            addTab(new QPushButton("Hi 2!"), "Button 2 Tab");
            tabBar()->setTabTextColor(0, QColor(Qt::red));
            tabBar()->setTabTextColor(1, QColor(Qt::blue));
        }
    };
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
    
        TabWidget tabWidget;
    
        tabWidget.show();
        return app.exec();
    }
    

    If you need more control, you can make your own tab widget. According to the docs, QTabWidget is basically just a QStackedWidget combined with a QTabBar. You can make your own tab widget by combining a QStackedWidget with, for example, a set of stylized QPushButtons.

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

Sidebar

Related Questions

I'd like to have a QTableWidget that has 2 'header' rows. Essentially I'd like
I have a QTableWidget and would like that pressing Ctrl while clicking on a
I have Tab Layout that contains a TextView. I'd like to assign some text
I would like to have a header with a menu and to be able
Let's consider we have QWidget that contains QTableWidget (only). So we want to resize
I have QTabWidget on my form and two tabs on it. These tabs have
I would like to have one column in QTableWidget NOT editable. In forums I
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have a QTableWidget that I populate like this: // Clear the table this->topPatchesTableWidget->setRowCount(0);
I need to make the tabs that I have oriented at the bottom of

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.