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, margins.right() + frameWidth + pad + buttonWidth, margins.bottom() + frameWidth);
29 connect(
this, &ClearComboBox::currentTextChanged,
this, &ClearComboBox::handleTextChanged);
41 void ClearComboBox::handleTextChanged(
const QString &
text)
46 void ClearComboBox::handleClearButtonClicked()
53 return currentText().isEmpty();