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 QTabBar of concrete QTabWidget
Qt 6.11 is out! See what's new in the release blog

Styling QTabBar of concrete QTabWidget

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 479 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.
  • W Offline
    W Offline
    warren450
    wrote on last edited by
    #1

    Hello,
    I am creating my first app in QT and I need to have 2 differently styled QTabWidgets. I styled the first one with something like this in .qss file:

    @ QTabWidget::tab-bar {
    left: 5px;
    }
    QTabBar::tab {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
    stop: 0 #E1E1E1, stop: 0.4 #DDDDDD,
    stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
    }

    ... (there is more of it but it isnt very relevant)
    @

    Now the problem is, that I cant find a way to change style of the second QTabWidget because I cant find a way to specify his QTabBar. Via QT creator I have created QTabWidget and named it GraphTabWidget and into .qss file I wrote:

    @QTabWidget#GraphTabWidget:pressed { //This worked fine
    background-color: red;
    }@

    and

    @QTabBar#GraphTabWidget:tab { //This has no effect
    background-color: black
    }@

    So the question is: What do I need to write to .qss file to change style of QTabBar of my GraphTabWidget?

    I have also tried to use @ui->GraphTabWidget->tabBar()->setStyleSheet(); @
    but it did really strange things (I could change a color of borders, but nothing else and even when I used 'setStyleSheet("")' it didnt reset the style to default).

    I will much appreciate any help :)

    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