Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Avoid pixelated color button appearance on hidpi
  • Loading branch information
nyalldawson committed May 12, 2023
1 parent 367b8ba commit c87d64b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/gui/qgscolorbutton.cpp
Expand Up @@ -734,12 +734,16 @@ void QgsColorButton::setButtonBackground( const QColor &color )
}

//create an icon pixmap
QPixmap pixmap( currentIconSize );
const double pixelRatio = devicePixelRatioF();
QPixmap pixmap( currentIconSize * pixelRatio );
pixmap.setDevicePixelRatio( pixelRatio );
pixmap.fill( Qt::transparent );

if ( backgroundColor.isValid() )
{
const QRect rect( 0, 0, currentIconSize.width(), currentIconSize.height() );
const QRectF rect( 0, 0,
currentIconSize.width(),
currentIconSize.height() );
QPainter p;
p.begin( &pixmap );
p.setRenderHint( QPainter::Antialiasing );
Expand Down

0 comments on commit c87d64b

Please sign in to comment.