Skip to content

Commit

Permalink
Hacky workaround for incorrect widget size on first display on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro authored and nyalldawson committed Jan 23, 2023
1 parent c960802 commit 9e01963
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/gui/qgscolorwidgets.cpp
Expand Up @@ -511,9 +511,26 @@ void QgsColorWheel::createImages( const QSizeF size )

void QgsColorWheel::resizeEvent( QResizeEvent *event )
{
QgsColorWidget::resizeEvent( event );
#ifdef Q_OS_WIN
// For some reason the first reported size than that of the parent widget, leading to a cut-off color wheel
if ( event->size().width() > parentWidget()->size().width() )
{
QSize newSize(
std::min( event->size().width(), parentWidget()->size().width() - 2 ),
std::min( event->size().height(), parentWidget()->size().height() - 2 )
);
resize( newSize );
createImages( newSize );
}
else
{
createImages( event->size() );
}
#else
//recreate images for new size
createImages( event->size() );
QgsColorWidget::resizeEvent( event );
#endif
}

void QgsColorWheel::setColorFromPos( const QPointF pos )
Expand Down

0 comments on commit 9e01963

Please sign in to comment.