@@ -46,7 +46,6 @@ QgsStatusBarCoordinatesWidget::QgsStatusBarCoordinatesWidget( QWidget *parent )
46
46
47
47
mLineEdit = new QLineEdit ( this );
48
48
mLineEdit ->setMinimumWidth ( 10 );
49
- mLineEdit ->setMaximumWidth ( 300 );
50
49
// mLineEdit->setMaximumHeight( 20 );
51
50
mLineEdit ->setContentsMargins ( 0 , 0 , 0 , 0 );
52
51
mLineEdit ->setAlignment ( Qt::AlignCenter );
@@ -226,10 +225,9 @@ void QgsStatusBarCoordinatesWidget::showMouseCoordinates( const QgsPointXY &p )
226
225
mLineEdit ->setText ( QgsCoordinateUtils::formatCoordinateForProject ( p, mMapCanvas ->mapSettings ().destinationCrs (),
227
226
mMousePrecisionDecimalPlaces ) );
228
227
229
- if ( mLineEdit ->width () > mLineEdit ->minimumWidth () )
230
- {
231
- mLineEdit ->setMinimumWidth ( mLineEdit ->width () );
232
- }
228
+ // ensure the label is big (and small) enough
229
+ mLineEdit ->setMinimumWidth ( mLineEdit ->fontMetrics ().width ( mLineEdit ->text () ) + 10 );
230
+ mLineEdit ->setMaximumWidth ( mLineEdit ->fontMetrics ().width ( mLineEdit ->text () ) + 10 );
233
231
}
234
232
235
233
@@ -244,9 +242,7 @@ void QgsStatusBarCoordinatesWidget::showExtent()
244
242
QgsRectangle myExtents = mMapCanvas ->extent ();
245
243
mLabel ->setText ( tr ( " Extents:" ) );
246
244
mLineEdit ->setText ( myExtents.toString ( true ) );
247
- // ensure the label is big enough
248
- if ( mLineEdit ->width () > mLineEdit ->minimumWidth () )
249
- {
250
- mLineEdit ->setMinimumWidth ( mLineEdit ->width () );
251
- }
245
+ // ensure the label is big (and small) enough
246
+ mLineEdit ->setMinimumWidth ( mLineEdit ->fontMetrics ().width ( mLineEdit ->text () ) + 10 );
247
+ mLineEdit ->setMaximumWidth ( mLineEdit ->fontMetrics ().width ( mLineEdit ->text () ) + 10 );
252
248
}
0 commit comments