Results 1 to 4 of 4

Thread: QTabBar tab color

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default QTabBar tab color

    Hi, all.

    I'm looking for an idea how to make QTabBar to have different color tabs. Qt's Style Sheet engine allows to specify styles for all/selected/first/last tabs, but not each one separately by index. Can anybody advise anything?

    Thanks.
    Oleg Shparber

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QTabBar tab color

    You could subclass QTabBar and write your own paint event. Have a look inside the sources how the original paint even looks like. Then just alter the for loop which is painting the tabs.

  3. The following user says thank you to Lykurg for this useful post:

    Oleg (29th March 2010)

  4. #3
    Join Date
    Mar 2008
    Posts
    16
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: QTabBar tab color

    You can use QTabBar::setTabTextColor ( int index, const QColor & color ) to set different colors for tabs.

  5. #4
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Thanks
    10
    Thanked 27 Times in 22 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: QTabBar tab color

    Quote Originally Posted by foxyproxy View Post
    You can use QTabBar::setTabTextColor ( int index, const QColor & color ) to set different colors for tabs.
    QTabBar::setTabTextColor ( int index, const QColor & color ) sets text color, not tab background color.

    Is there a way to implement stylesheet handler plugin for my own widget to has its own stylesheet? I'd like to have something like
    Qt Code:
    1. MyColorTabBar[tabIndex=1] {
    2. background-color: red;
    3. }
    4. MyColorTabBar[tabIndex=2] {
    5. background-color: green;
    6. }
    To copy to clipboard, switch view to plain text mode 
    Oleg Shparber

Similar Threads

  1. QTabBar and different background color
    By smrtak in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2012, 16:49
  2. QTabBar color in space inbetween tabs
    By AwDogsgo2Heaven in forum Newbie
    Replies: 1
    Last Post: 12th March 2010, 08:44
  3. Replies: 3
    Last Post: 22nd January 2010, 16:46
  4. Display Label Color by selecting Color Picker
    By sosanjay in forum Qt Programming
    Replies: 1
    Last Post: 25th September 2009, 06:11
  5. how to change backgroup color, button color and shape?
    By lzha022 in forum Qt Programming
    Replies: 10
    Last Post: 16th June 2008, 22:25

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.