[SOLVED] Customize QMdiArea QTabBar
-
My application has 2 QMdiAreas side by side with tabbed subwindows.
Subwindows and thus tabs are closable.In both QTabBars active subwindow tabs are displayed with close buttons displaying its active status (enabled icon of close button)
But I need to make only 1 tab appear to be active. So I do some custom handling to keep track of "active" mdi area.
I can customize appearance of selected tab,
but I also want to be able to customize appearance close tab behavior.Basically I only need to make on the specific mdi area all close tabs (even for active subwindow) to display inactive icon instead of active.
I tried to set stylesheet to QTabBar as below
@ tabBar->setStyleSheet(
"QTabBar::close-button {"
"image: url(:/trolltech/styles/commonstyle/images/standardbutton-closetab-16.png);"
"}"
);@But this always displays active icon of close button and I need disable (unless howered).
And I would prefer not to create custom images.Am I missing any better way to do it?
Thanks in advance,
Alex -
@void CustomizeMdiProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget ) const
{
Q_CHECK_PTR( widget );
Q_CHECK_PTR( option );if( !buttonParent.isNull() && widget && buttonParent.data()!= widget && element == QStyle::PE_IndicatorTabClose && option )
{
const QTabBar* tabBar = qobject_cast<const QTabBar*>(widget);
Q_CHECK_PTR( tabBar );QStyleOption opt( *option );
opt.state &= ~( QStyle::State_Selected );QProxyStyle::drawPrimitive ( element, &opt, painter, widget );
}
else
QProxyStyle::drawPrimitive(element, option, painter, widget);
}@Solution can be broken in case of current implementation change but has the desired visual effect and keeps current style.
Thanks Andre for suggestion.