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. Styling a specific tab in a tab bar

Styling a specific tab in a tab bar

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 953 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.
  • R Offline
    R Offline
    riddleam
    wrote on last edited by
    #1

    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?
    Thanks!

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

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

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

      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