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

Changing QTabBar::tab border color breaks the width & padding?



  • I was styling my app and ran into some weird behavior when trying to override border colors, and was able to narrow it down to this minimal example...

    With no styling my tabs look like this:

    1923412d-dbf4-4409-b476-c9904668be6b-image.png

    But when I apply any border related styling like the snippet below, it changes to this:

    bca2fa31-5ec6-44ec-b700-9cd251be9c62-image.png

    QTabBar::tab {
        border-color: black;
    }
    

    Can anyone please help me understand why this is happening? I'd like to change colors without side-effects like this


  • Moderators

    Without stylesheet a platform plugin is used to draw controls. When you set a border with qss the style for the control is changed to use the qss style with everything you didn't set left at defaults (no border, transparent background, no padding etc.).
    Text color is sort of an exception, because it only overrides the palette, but for the most part when you use stylesheets it's all or nothing. If you want a custom qss border you need to recreate the rest of the native look i.e. set border (not just color), background and padding.


  • Lifetime Qt Champion

    @Esor I guess you're overwriting the default style sheet with your own which only defines the border color, everything else is lost then. Check the default style-sheet.


  • Moderators

    Without stylesheet a platform plugin is used to draw controls. When you set a border with qss the style for the control is changed to use the qss style with everything you didn't set left at defaults (no border, transparent background, no padding etc.).
    Text color is sort of an exception, because it only overrides the palette, but for the most part when you use stylesheets it's all or nothing. If you want a custom qss border you need to recreate the rest of the native look i.e. set border (not just color), background and padding.



  • Ok thanks for the replies, I will try to recreate the Fusion style with my own QSS and colors



  • This post is deleted!

Log in to reply