Important: Please read the Qt Code of Conduct -

Styling a specific tab in a tab bar

  • Hello, I've been trying to style a specific tab (not them all) in a tab widget, but I haven't been able to pull it off.

    There doesn't appear to be a way to identify a certain tab in QSS or set some identifier like you can with regular widgets.
    Icons won't work in this case, because I am using an image sheet for the button, where the normal state is on the top half and the hover state is on the bottom.

    What I'm trying to do is essentially this in QSS:

    QTabBar::tab[accessibleName="firstTab"] {
        background-image: url(:/images/button.png);
        background-position: top;
        height: 25px;
    QTabBar::tab:hover[accessibleName="firstTab"] {
        background-position: bottom;

    But accessibleNames aren't an option on individual tabs.
    What can I do about this?

  • Lifetime Qt Champion

    Im not sure you can.
    At least i could not get it to use #name nor property [] on the subcontrol

    I ended up using
    void QTabWidget::setTabIcon(int index, const QIcon &icon) and
    would draw the decorations on the Icon.

Log in to reply