Skip to content

Commit 26b86ba

Browse files
committedJun 14, 2019
Limit the maximum width of legend embedded widgets
Since column is resized to contents, limit the expanded width of embedded widgets, if they are not already limited. Else, embedded widget may grow very wide due to large legend graphics.
1 parent a79f2ba commit 26b86ba

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed
 

‎src/gui/layertree/qgslayertreeview.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,16 @@ void QgsLayerTreeView::modelRowsInserted( const QModelIndex &index, int start, i
159159
if ( QgsLayerTreeEmbeddedWidgetProvider *provider = QgsGui::layerTreeEmbeddedWidgetRegistry()->provider( providerId ) )
160160
{
161161
QModelIndex index = layerTreeModel()->legendNode2index( legendNodes[i] );
162-
setIndexWidget( index, provider->createWidget( layer, i ) );
162+
QWidget *wdgt = provider->createWidget( layer, i );
163+
// Since column is resized to contents, limit the expanded width of embedded widgets,
164+
// if they are not already limited, e.g. have the defaut MAX value.
165+
// Else, embedded widget may grow very wide due to large legend graphics.
166+
// TODO: Max width could be a configured setting.
167+
if ( wdgt->maximumWidth() == QWIDGETSIZE_MAX )
168+
{
169+
wdgt->setMaximumWidth( 250 );
170+
}
171+
setIndexWidget( index, wdgt );
163172
}
164173
}
165174
}

0 commit comments

Comments
 (0)
Please sign in to comment.