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. Changing QTabBar::tab border color breaks the width & padding?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 535 Views
  • 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.
  • E Offline
    E Offline
    Esor
    wrote on last edited by
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #3

      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.

      1 Reply Last reply
      2
      • E Esor

        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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @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.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #3

          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.

          1 Reply Last reply
          2
          • E Offline
            E Offline
            Esor
            wrote on last edited by
            #4

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

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Esor
              wrote on last edited by
              #5
              This post is deleted!
              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