PDA

View Full Version : QStyle for TabWidget/HeaderView



VireX
4th June 2007, 01:06
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. :D

wysota
4th June 2007, 07:18
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().

VireX
6th June 2007, 04:26
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.

wysota
6th June 2007, 11:25
Do you use WindowsXP or Vista?

VireX
6th June 2007, 21:12
I use Windows XP with a Vista Theme (it edited the system files)

wysota
6th June 2007, 22:00
So palette won't work.You can't override the system theme.

VireX
6th June 2007, 22:35
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?

wysota
7th June 2007, 02:09
Because this is still a system style :) Try running your app with the Plastique style.

VireX
7th June 2007, 03:08
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.

wysota
7th June 2007, 10:19
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?

VireX
8th June 2007, 21:35
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()?

wysota
11th June 2007, 10:16
I can't answer that question without exactly knowing what you did. It looks like you used both the palette and the css approach.

VireX
11th June 2007, 21:18
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.