5 #include <QStyleOptionComboBox>
21 const QMargins margins = contentsMargins();
22 QStyleOptionComboBox opt;
24 const int frameWidth = style()->pixelMetric(QStyle::PM_ComboBoxFrameWidth, &opt,
this);
26 const int buttonWidth = style()->subControlRect(QStyle::CC_ComboBox, &opt, QStyle::SC_ComboBoxArrow,
this).width();
27 buttonLayout()->setContentsMargins(margins.left() + frameWidth + pad, margins.top() + frameWidth,
28 margins.right() + frameWidth + pad + buttonWidth, margins.bottom() + frameWidth);
30 connect(
this, &ClearComboBox::currentTextChanged,
this, &ClearComboBox::handleTextChanged);
43 void ClearComboBox::handleTextChanged(
const QString &
text)
48 void ClearComboBox::handleClearButtonClicked()
55 return currentText().isEmpty();