New KTabWidget

Zack Rusin zack at
Wed Feb 26 20:14:47 GMT 2003

On Wednesday 26 February 2003 14:58, Aaron J. Seigo wrote:
> On Wednesday 26 February 2003 11:53, Zack Rusin wrote:
> > This is simply impossible.One could make it look "kind-of" like
> > tabs but never like the actual style drawn tabs (because it's
> > impossible to derive the damn thing from QTabBar because of it's
> > messed up drawing routins). The only way to do it properly is to
> > actually fix QTabBar/QTabWidget.
> fixing QTab* would be the best, but on the off chance that this
> simply isn't posible, would it not be possible to use the QStyle
> primitives as QTabBar does to draw styled widgets? i know that's a
> pain in patoot, but it would mean having a tab widget that, well,
> looks like a tab widget. =)

Unfortunately it's impossible. TabBar is drawn using 
"void QStyle::drawControl ( ControlElement element, QPainter * p, const 
QWidget * widget, const QRect & r, const QColorGroup & cg, SFlags how = 
Style_Default, const QStyleOption & opt = QStyleOption::Default ) 
const;" method. 
The widget in that method can always be casted to the widget we're 
drawing. So if the ControlElement is CE_TabBarTab then the widget can 
be casted to QTabBar. We can't inherit QTabBar because the arrow 
drawing routines are private and we don't have any control, whatsoever, 
over them. So now we have a widget that simply can't be casted to 
QTabBar and we're pretty much done because styles do cast that widget 
so we'd break all the styles. Of course a possible hackish solution 
could be to add casting operator to that new widget and make it 
construct and return a new qtabbar for the purpose of styles (they only 
need it to get some basic info - e.g. total number of tabs ) but then 
again that's just a nasty hack.


Instructions should be read first, or not at all.
Anything else is admitting defeat...

More information about the kde-core-devel mailing list