SettingsDialog: Update size of category view on showing/hiding scrollbar

On a german locale the category view has a horizontal scrollbar. This is
because the initial sizeHint is calculated while the vertical scrollbar
is not visible. This patch ensures that the sizeHint is updated if the
scrollbar is shown.

Change-Id: Ic97c0c3650f765dbf6d8f84f2c168630c65ee89f
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Daniel Teske
2013-06-12 19:12:35 +02:00
parent fa36673ee1
commit cdecaa5a80

View File

@@ -248,6 +248,7 @@ public:
{
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
setItemDelegate(new CategoryListViewDelegate(this));
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
}
virtual QSize sizeHint() const
@@ -257,6 +258,16 @@ public:
width += verticalScrollBar()->width();
return QSize(width, 100);
}
// QListView installs a event filter on its scrollbars
virtual bool eventFilter(QObject *obj, QEvent *event)
{
if (obj == verticalScrollBar()
&& (event->type() == QEvent::Show
|| event->type() == QEvent::Hide))
updateGeometry();
return QListView::eventFilter(obj, event);
}
};
// ----------- SettingsDialog