Results 1 to 2 of 2

Thread: Tabified QDockWidget, QTabWidget, and Style Sheets

  1. #1
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Tabified QDockWidget, QTabWidget, and Style Sheets

    I've run into a problem. I have a QTabWidget inside a QDockWidget. My QMainWindow class allows for tabified QDockWidgets. My problem is setting the style sheet for the QTabBar and QTabWidget. I want to style the QDockWidget tabs differently but the QTabWidget inside the QDockWidget uses both the style I set for the QDockWidget it is in as well as the style sheet I set for it.

    I thought I may be able to correct this behavior if I reclassed the QTabBar the QMainWindow class uses for tabified QDockWidgets, however I cannot find a way the QMainWindow class creates it. There is a QTabBar that shows as one of the children of my QMainWindow class.

    By reclassing the classes I would be able to use the new variable name for the style sheets and I think this would prevent my overrun problem. Without it I am stuck using the base QTabBar as a style sheet reference.

    Can anyone help with this? Perhaps there is another way to style the QDockWidget tabs seperately from a contained QTabWidget.

  2. #2
    Join Date
    Feb 2010
    Posts
    96
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Tabified QDockWidget, QTabWidget, and Style Sheets

    Well ... this seems a bit unfair for developers. The QTabBar is private and I cannot reclass it. However I did find a work around. In PyQt it looks something like this

    In the QMainWindow class
    Qt Code:
    1. for c in self.children():
    2. if isinstance(c, QTabBar):
    3. style = theme.getStyle()
    4. c.setStyleSheet(style); break
    To copy to clipboard, switch view to plain text mode 

    I would appreciate it if Qt gave us access to the event that creates the QTabBar so we can handle it better. In the meantime this works because the QDockWidget parent doesn't receive the styles for QTabBar and QTabWidget.

Similar Threads

  1. move/drag tabified QDockWidget's togeter
    By qtui in forum Qt Programming
    Replies: 0
    Last Post: 14th February 2011, 00:01
  2. Do Qt Style Sheets support List-style-image?
    By daiheitan in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2010, 01:41
  3. QDockWidget: Check tabified visibility?
    By youkai in forum Qt Programming
    Replies: 5
    Last Post: 19th July 2009, 09:44
  4. Qt style sheets
    By locus in forum Qt Programming
    Replies: 5
    Last Post: 5th April 2007, 17:03
  5. style sheets
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 29th March 2007, 15:14

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.