diff --git a/python/gui/auto_generated/qgspixmaplabel.sip.in b/python/gui/auto_generated/qgspixmaplabel.sip.in index 496947aaf666..fe262dab4d4e 100644 --- a/python/gui/auto_generated/qgspixmaplabel.sip.in +++ b/python/gui/auto_generated/qgspixmaplabel.sip.in @@ -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(); + }; /************************************************************************ diff --git a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp index f097c10f5ed1..c9dd94a73597 100644 --- a/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp +++ b/src/gui/editorwidgets/qgsexternalresourcewidgetwrapper.cpp @@ -249,7 +249,6 @@ void QgsExternalResourceWidgetWrapper::updateValues( const QVariant &value, cons mQgsWidget->setDocumentPath( value.toString() ); } } - } void QgsExternalResourceWidgetWrapper::setEnabled( bool enabled ) diff --git a/src/gui/qgsexternalresourcewidget.cpp b/src/gui/qgsexternalresourcewidget.cpp index c7fc18536290..86a0bf5008db 100644 --- a/src/gui/qgsexternalresourcewidget.cpp +++ b/src/gui/qgsexternalresourcewidget.cpp @@ -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(); } } diff --git a/src/gui/qgspixmaplabel.cpp b/src/gui/qgspixmaplabel.cpp index b5d8bcfd9cbd..b6c26bab0bb1 100644 --- a/src/gui/qgspixmaplabel.cpp +++ b/src/gui/qgspixmaplabel.cpp @@ -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(); } diff --git a/src/gui/qgspixmaplabel.h b/src/gui/qgspixmaplabel.h index 7340c513a614..56e4b8f82183 100644 --- a/src/gui/qgspixmaplabel.h +++ b/src/gui/qgspixmaplabel.h @@ -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; };