@@ -2008,11 +2008,12 @@ QRect Style::tabWidgetTabBarRect(const QStyleOption *option, const QWidget *widg
20082008 // horizontal positioning
20092009 bool verticalTabs (isVerticalTab (tabOption->shape ));
20102010 if (verticalTabs) {
2011- tabBarRect.setTop (option->rect .top () + 1 );
2012- tabBarRect.setBottom (option->rect .bottom () - 1 );
2013- // tabBarRect.setHeight( qMin( tabBarRect.height(), rect.height() - 2 ) );
2014- // if( tabBarAlignment == Qt::AlignCenter ) tabBarRect.moveTop( rect.top() + ( rect.height() - tabBarRect.height() )/2 );
2015- // else tabBarRect.moveTop( rect.top()+1 );
2011+ tabBarRect.setHeight (qMin (tabBarRect.height (), rect.height () - 2 ));
2012+ if (tabBarAlignment == Qt::AlignCenter) {
2013+ tabBarRect.moveTop (rect.top () + (rect.height () - tabBarRect.height ()) / 2 );
2014+ } else {
2015+ tabBarRect.moveTop (rect.top () + 1 );
2016+ }
20162017 } else {
20172018 // account for corner rects
20182019 // need to re-run visualRect to remove right-to-left handling, since it is re-added on tabBarRect at the end
@@ -2022,8 +2023,13 @@ QRect Style::tabWidgetTabBarRect(const QStyleOption *option, const QWidget *widg
20222023 rect.setLeft (leftButtonRect.width ());
20232024 rect.setRight (rightButtonRect.left () - 1 );
20242025
2025- tabBarRect.moveLeft (rect.left () + 1 );
2026- tabBarRect.setWidth (rect.width () - 2 );
2026+ tabBarRect.setWidth (qMin (tabBarRect.width (), rect.width () - 2 ));
2027+
2028+ if (tabBarAlignment == Qt::AlignCenter) {
2029+ tabBarRect.moveLeft (rect.left () + (rect.width () - tabBarRect.width ()) / 2 );
2030+ } else {
2031+ tabBarRect.moveLeft (rect.left () + 1 );
2032+ }
20272033
20282034 tabBarRect = visualRect (option, tabBarRect);
20292035 }
0 commit comments