diff --git a/resources/css/style.css b/resources/css/style.css index 63a8657..54a2f1a 100644 --- a/resources/css/style.css +++ b/resources/css/style.css @@ -176,15 +176,17 @@ QTabWidget::pane { border-top: 1px solid #ccc; } +/* paintEvent of src/tabbar.cpp references the value of border and padding */ QTabBar::tab { border: 1px solid #ccc; border-radius: 0; - padding: 2px; + padding: 4px; + padding-top: 6px; } QTabBar::tab:selected { background-color: white; - border-bottom: 2px solid white; + border-bottom: 1px solid white; } QTabBar::tab:first { diff --git a/src/tabbar.cpp b/src/tabbar.cpp index cf6b720..a3b2d78 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -425,8 +425,22 @@ void TabBar::paintEvent(QPaintEvent *e) bool textRightToLeft = tab_title.isRightToLeft(); bool appRightToLeft = QWidget::isRightToLeft(); + // See QTabBar::tab::padding value in resources/css/style.css + const int padding = 4; QRect tabTextRect = style()->subElementRect(QStyle::SE_TabBarTabText, &tabopt, this); +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) + // See QTabBar::tab::border value in resources/css/style.css + const int border = 1; + // Add Padding to left, right. Padding is 4px. Add 5 to account for + // Extra pixel from border. + tabTextRect.setX(tabTextRect.x() + padding + border); + tabTextRect.setWidth(tabTextRect.width() - padding - border); +#else + // Qt6 correctly adds left and right padding but now incorrectly adds + // top or bottom padding. + tabTextRect.setY(tabTextRect.y() - padding); +#endif QRect fontTextRect = fontMetrics().boundingRect(tab_title); if (fontTextRect.width() > tabTextRect.width())