Results 1 to 6 of 6

Thread: QTabBar and different background color

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QTabBar and different background color

    No need to subclass anything.
    Just use QPalette.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2

    Default Re: QTabBar and different background color

    Quote Originally Posted by high_flyer View Post
    No need to subclass anything.
    Just use QPalette.
    Can you give me little example how to set background color only for second tab?

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: QTabBar and different background color

    I didn't understand that you wanted each tab to have a different color, that is a different matter.

    Hmm... maybe you can work around it by setting an icon, and setting its size to the tab size...

    The other way (that I see) is to override the QTabBar:aintEvent() but you should know if you are up to it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4

    Default Re: QTabBar and different background color

    my bad english..

    Quote Originally Posted by high_flyer View Post
    The other way (that I see) is to override the QTabBar:aintEvent() but you should know if you are up to it.
    tihs function use some a private member of private class... looks very hard... i think QTabBar not have good support for override

    Quote Originally Posted by high_flyer View Post
    Hmm... maybe you can work around it by setting an icon, and setting its size to the tab size....
    this is good idea, but here can be problem with translation support ( tr() ), i must use icon + text, .. i try this way, thx for help

  5. #5
    Join Date
    Sep 2011
    Location
    Portugal
    Posts
    25
    Qt products
    Qt4
    Platforms
    MacOS X Windows
    Thanked 5 Times in 5 Posts

    Default Re: QTabBar and different background color

    I've tried to override paintEvent(), but without success so far.
    Was anyone able to do this?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.