PDA

View Full Version : How can you make a TabWidget have a flat border (not raised)?



Joachie
13th April 2009, 00:57
The default behavior for a TabWidget is to have its border (around the sides and bottom) as a raised style. I don't like this and it's counter to all the other widgets I've setup, which have no border and are flat. How can I force the tab border to do the same?

Many thanks.

lyuts
13th April 2009, 09:15
I know that for instance with lables you can use setFrameStyle(QFrame::Plain); But there is no such method for QTabWidget. So i looked through some docs and found that this is usually done with the help of QStyleOptionTabWidgetFrame.

Joachie
14th April 2009, 03:19
I know that for instance with lables you can use setFrameStyle(QFrame::Plain); But there is no such method for QTabWidget. So i looked through some docs and found that this is usually done with the help of QStyleOptionTabWidgetFrame.

Thanks, that seems like it would work. But, does this mean I have to subclass the tab widget and override the paint method? Is there anyway of creating the QStyleOptionTabWidgetFrame instance and assigning it to the tab widget instance?

lyuts
14th April 2009, 08:11
I haven't tried it myself, but I think you don't have to subclass QTabWidget.
Instead, take a look at this tab widget's method



void initStyleOption ( QStyleOptionTabWidgetFrame * option ) const


Looks like this is what you need. Create your style option and assign it.

Joachie
14th April 2009, 08:25
I haven't tried it myself, but I think you don't have to subclass QTabWidget.
Instead, take a look at this tab widget's method



void initStyleOption ( QStyleOptionTabWidgetFrame * option ) const


Looks like this is what you need. Create your style option and assign it.

The docs suggest that just initializes it, almost like initFrom.. But that would be redundant, so I'll try it and see if it works.

spirit
14th April 2009, 08:27
maybe this (http://doc.trolltech.com/4.5/stylesheet-examples.html#customizing-qtabwidget-and-qtabbar) can help you.