31 mCombo =
new QComboBox();
32 mCombo->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
40 QHBoxLayout *hLayout =
new QHBoxLayout();
41 hLayout->setContentsMargins( 0, 0, 0, 0 );
42 hLayout->addWidget( mCombo, 1 );
47 mWarningLabelContainer =
new QWidget();
48 QHBoxLayout *warningLayout =
new QHBoxLayout();
49 warningLayout->setContentsMargins( 0, 0, 0, 0 );
50 mWarningLabel =
new QLabel();
52 const int size =
static_cast<int>( std::max( 24.0, mCombo->minimumSize().height() * 0.5 ) );
53 mWarningLabel->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
54 const int labelMargin =
static_cast<int>( std::round( mCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
55 warningLayout->insertSpacing( 0, labelMargin / 2 );
56 warningLayout->insertWidget( 1, mWarningLabel );
57 mWarningLabelContainer->setLayout( warningLayout );
58 hLayout->addWidget( mWarningLabelContainer );
59 mWarningLabelContainer->hide();
63 setFocusPolicy( Qt::FocusPolicy::StrongFocus );
64 setFocusProxy( mCombo );
67 connect( mCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsScaleMethodWidget::updateWarning );