Skip to content
Permalink
Browse files
[editor widgets] Fix external resource's image not cleared when brows…
…ing from one feature to another
  • Loading branch information
nirvn authored and nyalldawson committed Jun 14, 2021
1 parent 5886bcb commit d88918bdbbe9b3a4baa4fd6ed66a7a85bf723b11
@@ -45,9 +45,12 @@ determined from the width with the given aspect ratio.
%End

public slots:

void setPixmap( const QPixmap & );
virtual void resizeEvent( QResizeEvent * );

void clear();

};

/************************************************************************
@@ -249,7 +249,6 @@ void QgsExternalResourceWidgetWrapper::updateValues( const QVariant &value, cons
mQgsWidget->setDocumentPath( value.toString() );
}
}

}

void QgsExternalResourceWidgetWrapper::setEnabled( bool enabled )
@@ -245,9 +245,13 @@ void QgsExternalResourceWidget::loadDocument( const QString &path )
ir.setAutoTransform( true );
QPixmap pm = QPixmap::fromImage( ir.read() );
if ( !pm.isNull() )
{
mPixmapLabel->setPixmap( pm );
}
else
{
mPixmapLabel->clear();
}
updateDocumentViewer();
}
}
@@ -56,6 +56,14 @@ QSize QgsPixmapLabel::sizeHint() const
void QgsPixmapLabel::resizeEvent( QResizeEvent *e )
{
QLabel::resizeEvent( e );
QLabel::setPixmap( mPixmap.scaled( this->size(),
Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
if ( !mPixmap.isNull() )
{
QLabel::setPixmap( mPixmap.scaled( this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
}

void QgsPixmapLabel::clear()
{
mPixmap = QPixmap();
QLabel::clear();
}
@@ -50,9 +50,13 @@ class GUI_EXPORT QgsPixmapLabel : public QLabel
QSize sizeHint() const override;

public slots:

void setPixmap( const QPixmap & );
void resizeEvent( QResizeEvent * ) override;
void clear();

private:

QPixmap mPixmap;
};

0 comments on commit d88918b

Please sign in to comment.