I have sub-classed QTabWidget and have two tabs in there. I have overridden ::resizeEvent() of QTabWidget to change the width of tabs, so they can take half of the width of QTabWidget. In TAB1 (left tab), I have a horizontal splitter (QSplitter), which divides the tab in two equal parts, in each of them displaying a different QWidget. It all works fine, except that QTabBar's top left X offset is a few pixel to the right. I think QTabBar itself is shifter a few pixels to the right. How do I fix this?
Here's the code:
void WelcomeTabWidget::resizeEvent(QResizeEvent *event) {
tabBar()->setMinimumWidth(event->size().width());
tabBar()->setContentsMargins(0, 0, 0, 0);
_splitter->setSizes({event->size().width() / 2, event->size().width() / 2});
//The line below does not have any effect, so might as well remove it.
QTabWidget::resizeEvent(event);
}
Here's what it visually looks like (the offset is marked at two places in red):
How do I fix this?
This was happening due to style sheets that were set for the overall application:
QTabWidget::tab-bar {
left: 5px; /* move to the right by 5px */
}
So, it's fine:)