24 #include <QToolButton>
31 clearButton->setIcon(QIcon::fromTheme(
"edit-clear-locationbar-rtl", QIcon::fromTheme(
"edit-clear")));
35 clearButton->setStyleSheet(
"QToolButton { border: none; padding: 0px; }");
38 connect(
clearButton, SIGNAL(clicked()),
this, SLOT(clear()));
39 connect(
this, SIGNAL(textChanged(
const QString &)),
this, SLOT(
updateClearButton(
const QString &)));
41 int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
42 setStyleSheet(QString(
"QLineEdit { padding-right: %1px; } ").arg(
clearButton->sizeHint().width() + frameWidth + 1));
43 QSize msz = minimumSizeHint();
44 setMinimumSize(qMax(msz.width(),
clearButton->sizeHint().height() + frameWidth * 2 + 2),
45 qMax(msz.height(),
clearButton->sizeHint().height() + frameWidth * 2 + 2));
52 int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
53 clearButton->move(rect().right() - frameWidth - size.width(),
54 (rect().bottom() + 1 - size.height())/2);