21 #include <QToolButton>
26 , mNullValue( nullValue )
30 btnClear->setCursor( Qt::ArrowCursor );
31 btnClear->setFocusPolicy( Qt::NoFocus );
32 btnClear->setStyleSheet(
"QToolButton { border: none; padding: 0px; }" );
35 connect(
btnClear, SIGNAL( clicked() ),
this, SLOT(
clear() ) );
37 connect(
this, SIGNAL( textChanged(
const QString& ) ),
this,
40 int frameWidth = style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
41 setStyleSheet( QString(
"QLineEdit { padding-right: %1px; } " )
42 .arg(
btnClear->sizeHint().width() + frameWidth + 1 ) );
44 QSize msz = minimumSizeHint();
45 setMinimumSize( qMax( msz.width(),
btnClear->sizeHint().height() + frameWidth * 2 + 2 ),
46 qMax( msz.height(),
btnClear->sizeHint().height() + frameWidth * 2 + 2 ) );
52 int frameWidth = style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
53 btnClear->move( rect().right() - frameWidth - sz.width(),
54 ( rect().bottom() + 1 - sz.height() ) / 2 );