Skip to content

Commit

Permalink
Limit heght of PixmapLabel to 20 pixels (#46069)
Browse files Browse the repository at this point in the history
Becoming smaller bring the pixmap to flickering
in some situations when resizing the attribute form

Co-authored-by: Damiano Lombardi <damiano@opengis.ch>
  • Loading branch information
qgis-bot and domi4484 committed Nov 16, 2021
1 parent 1a5f304 commit c82edcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/gui/qgspixmaplabel.cpp
Expand Up @@ -19,14 +19,18 @@
QgsPixmapLabel::QgsPixmapLabel( QWidget *parent )
: QLabel( parent )
{
this->setMinimumSize( 1, 1 );
}

void QgsPixmapLabel::setPixmap( const QPixmap &p )
{
const bool sizeChanged = ( p.size() != mPixmap.size() );
mPixmap = p;

if ( mPixmap.isNull() )
this->setMinimumHeight( 0 );
else
this->setMinimumHeight( PIXMAP_MINIMUM_HEIGHT );

if ( sizeChanged )
{
updateGeometry();
Expand Down Expand Up @@ -66,4 +70,5 @@ void QgsPixmapLabel::clear()
{
mPixmap = QPixmap();
QLabel::clear();
this->setMinimumHeight( 0 );
}
2 changes: 2 additions & 0 deletions src/gui/qgspixmaplabel.h
Expand Up @@ -59,6 +59,8 @@ class GUI_EXPORT QgsPixmapLabel : public QLabel

private:

static const int PIXMAP_MINIMUM_HEIGHT = 20;

QPixmap mPixmap;
};

Expand Down

0 comments on commit c82edcd

Please sign in to comment.