Results 1 to 12 of 12

Thread: StyleSheet for TabBar

  1. #1
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default StyleSheet for TabBar

    hi,

    How to display different styles for each tab in Qt designer.i'm using the code

    Qt Code:
    1. QTabBar::tab:first
    2. {
    3. background:red;
    4. }
    5. QTabBar::tab:last
    6. {
    7. background:white;
    8. }
    To copy to clipboard, switch view to plain text mode 


    i want to display other color for 2nd ,3rd etc..


    thanks in advance

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    try

    QTabBar page#1
    {
    /* ur color */
    }
    QTabBar page#2
    {
    /* ur color */
    }

    similarly u can give different colors to different pages in QTabBar, i.e. page#3, page#4..

  3. #3
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: StyleSheet for TabBar

    hi

    i have given like that but still its not working..

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    could you please show what u wrote

  5. #5
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    i have wrote like this

    Qt Code:
    1. QTabBar::tab:Page1
    2. {
    3. background:red;
    4. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    nope, try this

    QTabBar Page#1
    {
    background:red;
    }

    QTabBar Page#2
    {
    background:white;
    }

  7. #7
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    still its not working

  8. #8
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    hey, i used the QTabWidget and it works with it in the following way:

    QWidget#tab
    {
    background:#ededed;
    }

    QWidget#tab_2
    {
    background-color:#6c8bb6;
    }

    QWidget#tab_3
    {
    background-color:red;
    }

    QWidget#tab_4
    {
    background-color:#44638f;
    }

    where tab_2, tab_3 etc are the object names of each tab

  9. #9
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    hi,


    I want to change color of the Tab bars

  10. #10
    Join Date
    Oct 2008
    Location
    Beijing China
    Posts
    77
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: StyleSheet for TabBar

    Quote Originally Posted by sdastagirmca View Post
    hi,


    I want to change color of the Tab bars
    I'm afraid single tab cannot be controlled by style sheet via specified object name. Since QTabbar::tab is not a widget but a sub control of QTabbar widget, just like QCheckBox::indicator and QListView::item cannot distinguished from other indicator or item. What user can distinguish from others is the state, such like selected and hover. for example:
    Qt Code:
    1. QTabbar::tab:selected
    2. {
    3. }
    4. QTabbar::tab:hover
    5. {
    6. }
    To copy to clipboard, switch view to plain text mode 

  11. #11
    Join Date
    Jan 2009
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: StyleSheet for TabBar

    hi


    Its able to change the color of the first and last.But it is not possible for second tab.

    thanks in advance

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

    Default Re: StyleSheet for TabBar

    It's this you want: https://bugreports.qt-project.org/browse/QTBUG-840

    I've been trying to accomplish this as well, but without success.
    If there's anyone that has been able to do this, please post your solution.

Similar Threads

  1. Replies: 7
    Last Post: 12th January 2011, 22:01
  2. Styling QComoBox using CSS Stylesheet
    By bjoernbg in forum Qt Programming
    Replies: 1
    Last Post: 6th October 2010, 23:12
  3. Q_OBJECT and styleSheet
    By babu198649 in forum Newbie
    Replies: 1
    Last Post: 9th December 2008, 06:17
  4. Replies: 8
    Last Post: 17th March 2008, 14:04

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.