MiniProjectTargetSelector: Ensure selected item is visible on show event

Is useful when project contains large amount of targets and you have
to switch between them more or less often. Change also applies to other
tree views in selector but they are less likely to contain large
row counts.

Change-Id: Ic2cd920335adeef618d85202b3347a4cd042871c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Alexander Pershin
2023-05-19 23:16:54 +03:00
parent cae4dd01a8
commit cb05304858

View File

@@ -389,6 +389,12 @@ private:
TreeView::mouseReleaseEvent(event); TreeView::mouseReleaseEvent(event);
} }
void showEvent(QShowEvent* event) override
{
scrollTo(currentIndex());
TreeView::showEvent(event);
}
QObject *objectAt(const QModelIndex &index) const QObject *objectAt(const QModelIndex &index) const
{ {
return theModel()->itemForIndex(index)->object(); return theModel()->itemForIndex(index)->object();