From: OG Date: 4.9.2009 Follows: v4.5.2 Precedes: v4.6.0-tp1 Stylesheet: Do not crop the text in tabs Because we did not reiimplement SE_TabBarTabText to force the parentstyle to call the virtual function back, we got the normal style margins in addition to the one by the stylesheet. Also added test for !hasNativeBorder to suport cases where we just specify a border Reviewed-by: JBW Task-number: 196326 diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -1882,7 +1882,6 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, break; case CE_TabBarTabLabel: if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { - // ### consider merging this with SE_TabBarTabText QStyleOptionTabV3 tabV2(*tab); QRect tr = tabV2.rect; bool verticalTabs = tabV2.shape == QTabBar::RoundedEast diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3948,7 +3948,7 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q QFont oldFont = p->font(); if (subRule.hasFont) p->setFont(subRule.font); - if (subRule.hasBox()) { + if (subRule.hasBox() || !subRule.hasNativeBorder()) { tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r) : subRule.contentsRect(r); QWindowsStyle::drawControl(ce, &tabCopy, p, w); @@ -5702,6 +5702,15 @@ QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, c } break; } + case SE_TabBarTabText: + case SE_TabBarTabLeftButton: + case SE_TabBarTabRightButton: { + QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); + if (subRule.hasBox() || !subRule.hasNativeBorder()) { + return ParentStyle::subElementRect(se, opt, w); + } + break; + } #endif // QT_NO_TABBAR case SE_DockWidgetCloseButton: diff --git a/tests/auto/uiloader/baseline/css_tab_border.ui b/tests/auto/uiloader/baseline/css_tab_border.ui --- a/tests/auto/uiloader/baseline/css_tab_border.ui +++ b/tests/auto/uiloader/baseline/css_tab_border.ui @@ -0,0 +1,105 @@ + + + Form + + + + 0 + 0 + 379 + 277 + + + + Form + + + #tabWidget QTabBar::tab { + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, + stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3); + border: 2px solid #C4C4C3; + border-bottom-color: #C2C7CB; /* same as the pane color */ + border-top-left-radius: 4px; + border-top-right-radius: 4px; + padding: 2px; + } + +#tabWidget_2 QTabBar::tab { + border: 3px solid red; + } + +#tabWidget_3 QTabBar::tab { + margin: 5px; + } + + + + + + + + + 1 + + + true + + + + Tab 1 + + + + + Tab 2 + + + + + + + + 1 + + + false + + + + Tab 1 + + + + + Tab 2 + + + + + + + + 1 + + + true + + + + Tab 1 + + + + + Tab 2 + + + + + + + + + +