34 mCombo =
new QComboBox();
35 mCombo->setSizeAdjustPolicy( QComboBox::AdjustToMinimumContentsLengthWithIcon );
43 QHBoxLayout *hLayout =
new QHBoxLayout();
44 hLayout->setContentsMargins( 0, 0, 0, 0 );
45 hLayout->addWidget( mCombo, 1 );
50 mWarningLabelContainer =
new QWidget();
51 QHBoxLayout *warningLayout =
new QHBoxLayout();
52 warningLayout->setContentsMargins( 0, 0, 0, 0 );
53 mWarningLabel =
new QLabel();
55 const int size =
static_cast<int>( std::max( 24.0, mCombo->minimumSize().height() * 0.5 ) );
56 mWarningLabel->setPixmap( icon.pixmap( icon.actualSize( QSize( size, size ) ) ) );
57 const int labelMargin =
static_cast<int>( std::round( mCombo->fontMetrics().horizontalAdvance(
'X' ) ) );
58 warningLayout->insertSpacing( 0, labelMargin / 2 );
59 warningLayout->insertWidget( 1, mWarningLabel );
60 mWarningLabelContainer->setLayout( warningLayout );
61 hLayout->addWidget( mWarningLabelContainer );
62 mWarningLabelContainer->hide();
66 setFocusPolicy( Qt::FocusPolicy::StrongFocus );
67 setFocusProxy( mCombo );
70 connect( mCombo, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsScaleMethodWidget::updateWarning );