Skip to content

Commit

Permalink
TabWidget: Improve size hints
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesLorenz committed Jul 21, 2019
1 parent aa8f936 commit ba6a86d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/gui/widgets/TabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ QSize TabWidget::minimumSizeHint() const
for ( widgetStack::const_iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
{
maxWidth = std::max(maxWidth, it->w->width());
maxHeight = std::max(maxHeight, it->w->height());
maxWidth = std::max(maxWidth, it->w->minimumSizeHint().width());
maxHeight = std::max(maxHeight, it->w->minimumSizeHint().height());
}
// "-1" :
// in "addTab", under "Position tab's window", the widget is
Expand All @@ -335,7 +335,21 @@ QSize TabWidget::minimumSizeHint() const

QSize TabWidget::sizeHint() const
{
return minimumSizeHint();
if (m_resizable)
{
int maxWidth = 0, maxHeight = 0;
for ( widgetStack::const_iterator it = m_widgets.begin();
it != m_widgets.end(); ++it )
{
maxWidth = std::max(maxWidth, it->w->sizeHint().width());
maxHeight = std::max(maxHeight, it->w->sizeHint().height());
}
// "-1" :
// in "addTab", under "Position tab's window", the widget is
// moved up by 1 pixel
return QSize(maxWidth + 4, maxHeight + m_tabbarHeight - 1);
}
else { return QWidget::sizeHint(); }
}


Expand Down

0 comments on commit ba6a86d

Please sign in to comment.