Results 1 to 13 of 13

Thread: QStyle for TabWidget/HeaderView

  1. #1
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QStyle for TabWidget/HeaderView

    I been looking at the QStyle example, and I love how they did the wood theme. But I was wondering how I can use the standard style of QTabWidget and QHeaderView (for TableWidget and TreeWidget), but I want to color those two things in like some other color, almost like as if I take a screenshot of my program and hue+colorize the GUIs, so that it matches the rest of my program.

    The QStyle example program is sort of bloated with all sorts of style and confusing, so I'm not sure which ones belong to TabWidget + HeaderViews and which belong to like pushbutton etc which I don't need.

    Can anyone tell me which items/events that I should code up, in order to just plain colorize those objects? Maybe even scroll bar if its easy to do.

    Anyway thanks for the help and your effort to help me.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    I think it is enough to change the palette of the component you want to colorize. As for the roles in it for different items - it depends on the style used. You could try implementing a style proxy (see our wiki) and reimplement standardPalette() and/or drawComplexControl().

  3. #3
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    QPalette qp = Tab->palette();
    qp.setColor(QPalette::Window, QColor(255,255,255));
    Tab->setPalette(qp);

    This doesn't do anything, so I don't think changing palette works at all.

    I saw the proxy style thing, but i don't know what to edit and how to code it for my purpose. Theres so many styles and options and things, even after reading all of them I don't know what one to use to color it the way I want.
    Last edited by VireX; 6th June 2007 at 03:37.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    Do you use WindowsXP or Vista?

  5. #5
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    I use Windows XP with a Vista Theme (it edited the system files)

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    So palette won't work.You can't override the system theme.

  7. #7
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    I tried with Windows XP default Silver theme too, it didn't make a difference.
    So how do I code it so that I can change the color of the tabs?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    Because this is still a system style Try running your app with the Plastique style.
    Attached Images Attached Images

  9. #9
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    I tried changing the thing to triangular although it looks ugly it does color it with palette.

    Thats not the point tho, I want my tabwidget to look custom. My Question was how to use QStyle to change the style of the tabwidget to the way i want. not whether or not QPalette will work.

    I know plastique works with tabs, but then plastique can't edit MainWindow palettes, so it has its bad sides too. Anyway I want to know a way where I can continue to use Windows XP theme, except be able to change the style of how the tabs are colored and maybe even put a texture on it myself. Kind of like how you can define a texture in QTreeWidgetItem's.
    Last edited by VireX; 7th June 2007 at 02:17.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    You can subclass the style and reimplement drawComplexControl to draw the tab bar yourself. Unfortunately WindowsXP ignores the palette, so you can't just ask it do it. But maybe using stylesheets will be enough for your needs?

  11. #11
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    My friend figured it out, you use SetBrush with Plastique style, and it does everything I wanted.

    The only thing that bugs me now, is when I disable stuff in Plastique mode, it becomes BLACK and the etching done on it for disabled makes it look bad, is there a way to disable etching and/or make override the disabled black window color ? (I tried etch-disabled-text: 0px; but that didn't work)

    Also In the toolbar, in Plastique mode, the little sizegrip thing, turns black with white dots, and looks really bad with the gray stuff. Also when you highlight Toolbar buttons it turns black as well so u can't see text while hovering over them.

    Any solutions to these problems with maybe just palettes()?

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QStyle for TabWidget/HeaderView

    I can't answer that question without exactly knowing what you did. It looks like you used both the palette and the css approach.

  13. #13
    Join Date
    Jan 2007
    Posts
    209
    Thanks
    34
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStyle for TabWidget/HeaderView

    4.3.0 solves most of my CSS problems, actually 100% of the problems IN THIS thread.
    Just some bugs that ruined some of my other CSS things.

Similar Threads

  1. make MSN Messenger QStyle?
    By oob2 in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2007, 22:17
  2. Using QStyle and StyleSheet
    By informatics in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2007, 16:46
  3. Fonts, Colors, and QStyle
    By Jimmy2775 in forum Qt Programming
    Replies: 1
    Last Post: 28th September 2006, 07:26
  4. QStyle not styling
    By irudkin in forum Qt Programming
    Replies: 0
    Last Post: 25th April 2006, 10:52
  5. Why QStyle dosen't changes the standard font?
    By Dark_Tower in forum Newbie
    Replies: 8
    Last Post: 31st March 2006, 02:49

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.