void LineEditWidget::showEvent(QShowEvent *e) { // Width of standard QLineEdit plus extended tool buttons int width = 0; for (QWidget *w: _toolbuttons) { if (w->isVisible()) { width += w->width(); QAbstractButton *bt = qobject_cast<QAbstractButton*>(w); if (bt && bt->iconSize().height() > bt->height()) { bt->setIconSize(QSize(bt->height(), bt->height())); } } } setTextMargins(0, 0, width, 0); QLineEdit::showEvent(e); }