Results 1 to 3 of 3

Thread: QTabWidget style each tab differently

  1. #1
    Join Date
    May 2016
    Posts
    13

    Default QTabWidget style each tab differently

    Hi everyone,

    is it possible to style each tab of a QTabWidget differently while using e.g. the tabindex as the individual tabs are widgets?
    The setStyleSheet option only styles the whole QTabBar apart from using different states (: only-one, : first, : last, : middle, : previous-selected, : next-selected, : selected).

    Thanks!!

  2. #2
    Join Date
    Mar 2014
    Posts
    23
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default Re: QTabWidget style each tab differently

    I had a similar project long ago. QStyleSheets had not been of any use for this since they are pretty limited as you mentioned.

    My solution was to subclass from QTabWidget and to extend the paintEvent. There you can react on the current index and so on and draw some colors/gradients/borders as much as you like.

  3. #3
    Join Date
    Jul 2008
    Posts
    426
    Thanks
    9
    Thanked 55 Times in 53 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget style each tab differently

    Hi, you could try QTabBar::setTabButton and set different widgets for each tab.

    Ginsengelf

Similar Threads

  1. Replies: 3
    Last Post: 13th March 2016, 20:48
  2. Set style of QTabWidget created by QDockWindows
    By FelixB in forum Qt Programming
    Replies: 0
    Last Post: 8th June 2011, 15:37
  3. Replies: 3
    Last Post: 13th October 2009, 15:31
  4. How to change the style of QTabWidget
    By iamjayanth in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 12:07
  5. Copy QTabWidget style.
    By fanat9 in forum Qt Programming
    Replies: 0
    Last Post: 29th November 2007, 02:35

Tags for this Thread

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.