Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to remove the border beneath an active tab?



  • I am writing a QSS stylesheet and would like to replicate the look in Fusion where there is no border between the active tab and the pane:

    f6d31439-30ad-4c89-87e2-ea3057cb88b2-image.png

    When I apply my own stylesheet there is a border between them like this:

    9141cdf0-8c07-4477-9ccb-29c57232ea73-image.png

    I was reading through the reference docs and saw "Overlapping tabs for the selected state are created by using negative margins or using the absolute position scheme.", but it seems like tabs render underneath the pane and z-index isn't supported in QSS so I don't understand how that's possible, here's what it looks like with a large negative margin:

    980dc0e0-e6dd-4261-bbb6-921a63fd7faf-image.png



  • Ah I found the solution! Christian was correct that the border is for the pane which I already knew, but the problem is that if you disable it you get a blank patch beside the tabs:

    fb0becd8-613b-4c4e-9c34-9d522306e9a0-image.png

    I found the solution here and I don't really understand why it works and doesn't remove the top border like shown above, but it does. To get it working on all sides my solutions was this (I'm using a SCSS to QSS compiler):

    QTabWidget {
    
        &::pane {
            &:top {
                top: -1px;
            }
    
            &:bottom {
                bottom: -1px;
            }
    
            &:left {
                left: -1px;
            }
            &:right {
                right: -1px;
            }
    }
    

    6539a1ad-f227-4a77-a664-7c9a433a9ebb-image.png

    I'm still missing the border underneath the inactive tab which is not ideal but looks fine with my color set


  • Lifetime Qt Champion

    I don't think this border belongs to the tab but the widget below.



  • Ah I found the solution! Christian was correct that the border is for the pane which I already knew, but the problem is that if you disable it you get a blank patch beside the tabs:

    fb0becd8-613b-4c4e-9c34-9d522306e9a0-image.png

    I found the solution here and I don't really understand why it works and doesn't remove the top border like shown above, but it does. To get it working on all sides my solutions was this (I'm using a SCSS to QSS compiler):

    QTabWidget {
    
        &::pane {
            &:top {
                top: -1px;
            }
    
            &:bottom {
                bottom: -1px;
            }
    
            &:left {
                left: -1px;
            }
            &:right {
                right: -1px;
            }
    }
    

    6539a1ad-f227-4a77-a664-7c9a433a9ebb-image.png

    I'm still missing the border underneath the inactive tab which is not ideal but looks fine with my color set


Log in to reply